简体   繁体   English

为什么HTML注释缩进在浏览器中的显示方式不同?

[英]Why HTML comment indentation is displayed differently in browser?

I was trying to beautify my html so that whenever someone click view source on my page can see it. 我试图美化我的HTML,以便每当有人点击我的页面上的view source时都可以看到它。 So, I decided to write my name as a comment on top of my html. 所以,我决定把我的名字写在我的html之上作为评论。 However, what is shown on Google Chrome's view source was different from what I see in Notepad++. 但是,Google Chrome浏览器的view source显示的内容与我在Notepad ++中看到的不同。 Like in the picture : 如图所示:

在此输入图像描述

  • left = Google Chrome in view source mode. left =谷歌浏览器处于查看源模式。

  • right = Notepad++ 对= Notepad ++

Why I didn't get what I typed in notepad++ ? 为什么我没有得到我在记事本++中输入的内容? Is it because Notepad++ use different font with Google Chrome ? 是因为Notepad ++使用与谷歌浏览器不同的字体? If yes, what's the font used in Google Chrome ? 如果是,Google Chrome中使用的字体是什么?

How can I get what I want to display nicely on Google Chrome's view source? 如何在Google Chrome浏览器的视图源中获得我想要显示的内容?

PS I haven't tried it with other browsers yet. PS我还没有尝试过其他浏览器。

The problem I see there is word wrap. 我看到的问题是自动换行。 If your line of text is too long it will be wrapped to the next line. 如果您的文本行太长,它将被包装到下一行。 I doubt there is a solution for this except in making the message shorter and hoping the user window is wider than the message. 我怀疑有一个解决方案,除了使消息更短,并希望用户窗口比消息更宽。

It is very difficult (I would say impossible) to do this everywhere you want. 你想要的任何地方都很难(我会说不可能)。 I mean, the purpose of that visual appearance is to embellish your code on a platform; 我的意思是,视觉外观的目的是在平台上修饰你的代码; it differs from an editor to another whether character spacing, line wrapping or even word wrapping are used or not. 它与编辑器的区别在于是否使用字符间距,换行或甚至自动换行。 Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM