Even the new HTML5 tags aren\'t enough to describe structures without falling back to div
s. What\'s stopping me from changing:
You can use your own tags, but the problem is that since they're not standard, browsers won't know that they may have matching closing tags. And of course, the document won't validate as proper HTML/X-HTML.
<blah>
This is some <span>test</span> test text with another <bogus>tag</bogus> tag
within, which ends with a fake self-closing <tag />
</blah>
Browsers will see <blah>
, not now how to deal with it, and treat it as essentially "nothing" and ignore it. Then they'll happily parse away on to the next bit, and see some plain text, with a valid span inside. Eventually they'll reach the </blah>
and ignore that as well.
This is why Javascript and CSS had to support the opening HTML comment sequence as part of their respective language definitions:
<script type="text/javascript">
<!-- // <--actually a part of the javascript spec, treated as a comment.
alert('hey!');
//-->
</script>
When Javascript was first introduced, there were still MANY other browsers out there that were entirely unaware of Javascript, and so they'd ignore tags, and happily output your Javascript code. Ditto for CSS.
If you really need custom tags, you can produce the document as XML with your own DTD attached, and use XSLT to transform it into a valid HTML/X-HTML document.