1

Is there a way to make html comments visible in rendered html using css?

This won't work, but something to this effect:

htmlcomments {display: block;}

Would turn:

<p>Hi</p>

<!-- howdy -->

<p>There</p>

Into this:

Hi

Howdy

There

Use case: I'm making markdown documents with inline comments and I'd like to view them with their formatting and also show the comments in the document.

Thanks so much!

Waylan
  • 37,164
  • 12
  • 83
  • 109
David E
  • 37
  • 5
  • 2
    You will have to read the nodes (html comments are nodes of the parent element) then create an element containing the node.TextContent – Poul Bak Oct 17 '18 at 13:36
  • Sorry, I didn't quite understand that. Would that be something I'd do with a script? I'm working with markdown files (with html comments) on my local machine, is this solution possible this case? – David E Oct 17 '18 at 15:36
  • Most certainly not possible with CSS (see e.g. https://stackoverflow.com/questions/5688712/is-there-a-css-selector-for-text-nodes). Poul was talking about JavaScript. – mb21 Oct 18 '18 at 11:31

0 Answers0