[html5] HTML5 validator behavior issue
Ian Hickson
ian at hixie.ch
Tue Jan 18 00:23:45 PST 2011
On Tue, 18 Jan 2011, Jacob Kristensen wrote:
> >
> > It's invalid, and it would be ideal if the validator said it was
> > invalid, but for various reasons it's essentially impossible for the
> > validator to detect this particular mistake.
>
> Just a small question, why is it considered invalid? It seems perfectly
> reasonable to use the display property to hide content, (espicially when
> working with CSS based menus).
If it's purely a visual effect, e.g. you're using :hover menus, and the
page still makes perfect sense with CSS disabled, then it's not invalid.
What's invalid is writing a page where the CSS matters. For example, if
you have a game written in HTML and there's a <div> for what the game
looks like when it's the player's turn and a <div> for what the game looks
like when the AI is playing, then using CSS to toggle which one is visible
would be invalid because when CSS was disabled, or in CSS-less browsers,
the user would see _both_ <div>s all the time.
> In any case, what would you suggest web designers to use instead?
Right now, you don't have much choice but to use CSS, to be honest
(assuming you're targetting IE and older browsers).
In the future, in theory, if you want to hide something in the document
because that thing isn't relevant, then hidden="" will be the way to do
it, as in:
<div id="player-turn"> ... </div>
<div id="computer-turn" hidden> ... </div>
...with script toggling the "hidden" attribute. In CSS-less browsers of
the future (like search engines, some accessibility tools, etc), the
hidden="" attribute will still hide things even though CSS is off.
HTH,
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the Help
mailing list