Is using partial HTML comment in noscript to hide content when javascript is disable, guarantee to work everywhere?

Viewed 20

I want my website to work on text-based browsers like lynx

There's some part of the HTML that are useless in it like the profile photo

I tried the most upvoted solution put here Is there a HTML opposite to <noscript>?

which is

<head>
    <noscript><style> .jsonly { display: none } </style></noscript>
</head>

However Lynx does not hide it

What I found to work is doing this

<body>
    <noscript> <!--  </noscript>
         <img src="foobar.png">
    <noscript> -->  </noscript>
</body>

This works and it seems to work on all browsers I have tested, i.e the image is hidden when javascript is disabled, and shown otherwise.

However I would like to know if it is a documented behaviour in HTML5 parser or if it's just an edge case that everybody has implemented the same way ?

0 Answers
Related