HTML folding with inline comments

  • In Notepad++, using the “HTML” language option, a <tr> line with an inline comment fails to be recognised as foldable. The last closing “>” on the <tr> tag is shown in black whereas it should be shown in blue. I’m guessing the comment is confusing the syntax highlight and code folding. I’ve checked over this line and it looks correct. Is it me or is this a bug?

    I couldn’t include the code line here due to the spam protection on this forum.

    Many thanks

  • Hello Keith,

    I don’t create HTML files, myself ! So, when you say :

    a <tr> line with an inline comment fails to be recognised as foldable.

    Do you mean a line of the form :

    <tr>  <!-- Some comment text -->

    If I’m not mistaken, after opening an HTML file and regarding this part of the code, below ( don’t care about this exact code ! )

    <tr>  <!-- Some comment text -->
      <td height="20" align="center" valign="top">
        <table border="0" cellpadding="0" cellspacing="0" bgcolor="white">
          <tr><!-- Some other comment text -->

    On my 6.8.8 locale N++ configuration, the two <tr> tags, of the above example, are :

    • correctly displayed, in blue, even if the tag is just closed to the comment text

    • normally foldable and unfoldable

    Best Regards,


  • Hi. Thanks for replying. I did want to put the code into my post, but this forum won’t allow it (spam protection blocks it). I just tried again using a code block, but got the same message:-

    “Post content was flagged as spam by

    The comment is inside the tr tag itself (the comment is actually an ASP-style tag that gets replaced with data prior to the web server sending it).

  • Done it. Slightly changed my tr line and got it through

    	<tr class="lists" <!--#4dtext ([job header]job number)-->>

  • I am not a Notepad++ expert, nor am I an expert in the ins and outs of HTML syntax… however, the consensus in my searches seem to indicate that you cannot have valid HTML with a comment embedded inside a tag. (for example, and both indicate it’s not possible – though neither provides an explicit reference for it not being legal.)

    For HTML5, I was, however, able to piece together the following from the w3c HTML5 spec: the 6-step outline ( only indicates comments external to other elements; the elements definition ( explicitly allows comments to also be inside normal elements (ie, between start and end tags); however, the start tags section ( does not specify that comments are allowed inside the start tag (neither do the end tags or attributes definitions) – so I believe it’s thus not legal HTML5.

    However, as you clarified, your notation isn’t actually an HTML comment; it’s a server-side processor directive that never gets transmitted as HTML. As such, it doesn’t have to follow the rules for HTML, since it’s not HTML. However, as non-HTML, it’s somewhat unfair to expect an HTML syntax highlighter to properly understand every potential server-side extension that’s not part of HTML. However, if it’s a standard extension, such as ASP, I would expect setting the Notepad++ language to that language (such as ASP) would process correctly. And I see that setting to Language=ASP for your snippet also doesn’t highlight properly; I don’t know enough about ASP to know if it’s legal ASP or not, or whether your “ASP-style” means it’s not even really ASP.

  • Hi

    You are correct, the HTML only becomes valid at run-time. I just tested using some actual ASP code within a tr tag and Notepad++ recognises it properly, even with the Notepad++ Language set to HTML. Not unreasonable considering ASP is quite widely used.

    When I said ASP-style, the comment tags are actually for 4D ( which is not a well known development platform.

    I guess I was hoping that because my server-side tags are HTML comments and are already highlighted as such, that they could then be ignored for the remaining syntax highlighting/code folding.

    But since the syntax isn’t actually valid HTML in the editor, it’s fair that the syntax highlighting and code folding don’t recognise it. ;-(

    Thanks for the replies though.

  • So how do I turn this into a feature enhancement request?

    “Enhance HTML syntax highlight and code folding for comment based server side extensions inside HTML tags”

    Many thanks.

Log in to reply