简体   繁体   中英

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. So, I decided to write my name as a comment on top of my html. However, what is shown on Google Chrome's view source was different from what I see in Notepad++. Like in the picture :

在此输入图像描述

  • left = Google Chrome in view source mode.

  • right = Notepad++

Why I didn't get what I typed in notepad++ ? Is it because Notepad++ use different font with Google Chrome ? If yes, what's the font used in Google Chrome ?

How can I get what I want to display nicely on Google Chrome's view source?

PS I haven't tried it with other browsers yet.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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