I was writing a webpage today with a comment after the start of every major section. Instead of using a comment, which comes with the bulgy <!-- -->
syntax, could I instead put this in a data-*
attribute? This would be more for me than anything else, so I don't want to put it in an id
or class
, but it would also leave it open for userscripts to more easily parse the page.
Examples
My current method:
<article> <!-- news -->
<header> <!-- headline -->
<h1>How To Fix Everything</h1>
</header>
<section> <!-- news body -->
<p>This is the best magic there is:</p>
<ol>
<li>Find a problem</li>
<li>FIX IT</li>
<li>Back to step 1</li>
</ol>
</section>
<footer> <!-- social -->
<a href="//example.com/share">Share on Example.com!</a>
</footer>
</article>
My proposed method:
<article data-news>
<header data-headline>
<h1>How To Fix Everything</h1>
</header>
<section data-news-body>
<p>This is the best magic there is:</p>
<ol>
<li>Find a problem</li>
<li>FIX IT</li>
<li>Back to step 1</li>
</ol>
</section>
<footer data-social>
<a href="//example.com/share">Share on Example.com!</a>
</footer>
</article>