In theory, I could use anything, anywhere and style a <table>
into a <ul>
. Or style an <imsocool>
blue.
<style>
imsocool {
color: blue;
}
<imsocool>HELLO</imsocool>
Sometimes the validator complains (not like I care - it complains about "parse error" when validating calc()
s in css), but the browsers never do. The only problem I guess, is that browsers, screen readers, search engines, and everything else don't have any idea what <imsocool>
s are. Unknown tags don't have are, well, unknown. So when is this ok?
Is it ok to make special widgets like this (with JS, of course)?
<calendar>
<ctrlgroup>
<ctrl class="left"><-</ctrl>
<ctrl class="left">-></ctrl>
</ctrlgroup>
<week>
<day>1</day><day>2</day><day>3</day><!-- Etc. -->
</week>
</calendar>
Do I need to use dashes? (as the spec says - it's supposed to prevent conflicts with future elements)
<calendar-widget>
<ctrl-group>
<cal-ctrl class="left"><-</cal-ctrl>
<cal-ctrl class="left">-></cal-ctrl>
</ctrl-group>
<calendar-week>
<calendar-day>1</calendar-day><calendar-day>2</calendar-day><calendar-day>3</calendar-day><!-- Etc. -->
</calendar-week>
</calendar-widget>
Or should I not use it at all?
<div class="calendar">
<div class="controls">
<div class="left"><-</div>
<div class="left">-></div>
</div>
<div class="week">
<span class="day">1</span><span class="day">2</span><span class="day">3</span><!-- Etc. -->
</div>
</div>
Ignoring browser support, what are the pros and cons of using unknown HTML elements? When is it appropriate?
What I can think of:
- If no element in the spec fits the job good enough, there isn't going to be any semantic meaning lost -
<div>
doesn't mean any more than<imsocool>
. - Classes are annoying.
- It's a good idea to use the correct elements, if they exist (like use
<em>
for emphasis, not<big-and-red>
) - Don't abuse existing elements. You shouldn't style a
<table>
into a<ul>
- it'll confuse the robots (browser, accessibility software, google). So don't abuse possible future elements which might conflict?