Search code examples
htmldocumentationw3c

Proper way to document what the closing tag is closing


In my webpage, I have a lot of divs. I've been finding it very difficult, when seeing a few lines of closing tags - </div> s - to know which <div> it's closing.

I suppose I can use HTML comments to document which closing div corresponds to which opening div. I would use the div id in a comment near the closing tag.

But I feel like there must be a better way, despite the fact that Google turned up nothing relevant for my searches.

What is the best way to document closing divs?


Solution

  • I'm not sure there is a community held 'best way'. But I often use html comments and I know a lot of other developers do too, looking at the source code on well formatted sites will show you its an often used technique.

    <div id="some-id">
       ... Some Content ...
    </div><!-- some id -->
    

    This will read nicer if you have indentation for each of your block level elements.