HTML & CSS
I have found out from many documents on the net, that the <u> tag isn't supported in the XHTML strict doctype - whats the alternative that can be used for underlining?
Apply the following rule to a CSS class or id
From a usability POV it's best not to underline anything that isn't a link
is that the only way of doing it?
I believe so yes. I suppose you could add a bottom-border if you want, but i don't believe there's a specific tag for it. With XHTML & CSS you should be trying to separate presentation from content anyway (so CSS is the way forward)
It depends on why you want to underline a piece of text.
Is it a heading? Use <h1>-<h6>.
Is it an emphasized word? Use <em>.
Is it text that has been inserted after a document edit? Use <ins>.
Is it an instance of a term that is being defined? Use <dfn>.
And so forth. If HTML doesn't have an element type for the purpose then use a <span>.
Then you can alter the presentation of that element with CSS as described above.
The whole idea with Strict doctypes is the separation between content, presentation and behaviour. Underlining is presentation, so it should be handled via CSS.
As Simon said, choose the appropriate element type, add some way to reference it using an ID or class as splashpoint said, and assign a CSS rule to achieve the underlining.
BTW, this applies to HTML 4.01 Strict as well as XHTML 1.0 Strict and XHTML 1.1. It's not an XHTML vs HTML issue, it's a Strict vs Transitional thing.
Thanks guys for your help
style="text-decoration:underline;" is the best option.
no it isn't, inline styles are bad!
This topic is now closed. New replies are no longer allowed.