PDA

View Full Version : HTML or CSS


cg9com
05-02-2003, 09:01 PM
Hey all,
I was wondering which is better to format text with, practically.
An example would be using the bold element
as opposed to a CSS solution like font-weight.
Are the inline text formatting elements depricated in XHTML?

Catman
05-02-2003, 09:28 PM
This is a question I'm still asking myself. I see two distinct uses for bold face:

Activate the Submit Message button.

Join now or you'll regret it for the rest of your life.

Without CSS, I'd use <b> tags for the first and <strong> tags for the second. With CSS, I'd use <span> tags with font-weight set to bold for the first, but I'd still use <strong> tags for the second.

To my eye, the second has a semantic emphasis which would be lost by using span tags.

meow
05-03-2003, 12:39 AM
Originally posted by Catman
Are the inline text formatting elements depricated in XHTML?
Some but not all. Contrary to common belief for instance B is not deprecated.
http://www.w3.org/TR/html401/index/elements.html

XHTML1.0 or HTML4.01 doesn't matter for what's deprecated. What matters is if you write Strict or Transitional. Strict (X)HTML - deprecated elments and attributes can't be used.

brothercake
05-03-2003, 01:14 AM
I'd say don't use <b> and <i> because they have no semantic meaning. <strong> and <em> do have semantic meaning and can be interpreted as something other than visual; speech tone, for example.

Basically, use markup for semantic meaning and not for visual effect; never for visual effect (although there is a visual effect, obviously, but that's what CSS is for)

As a side note, I prefer not to assume implicit styling - specify font-weight:bold; for <strong> and font-style:italic; for <em>, if that's what you want them to be.

pardicity3
05-03-2003, 06:35 AM
Originally posted by brothercake
As a side note, I prefer not to assume implicit styling - specify font-weight:bold; for <strong> and font-style:italic; for <em>, if that's what you want them to be.
Interesting...so are you saying that perhaps one day, <strong> and <em> will be rendered differently than today? In fact, is there any place that says <em> has to be italic and <strong> has to be bold?

brothercake
05-03-2003, 02:06 PM
Originally posted by pardicity3
Interesting...so are you saying that perhaps one day, <strong> and <em> will be rendered differently than today?
Probably not, no.
Originally posted by pardicity3
In fact, is there any place that says <em> has to be italic and <strong> has to be bold?
No, and that's the point; if a certain effect is what you want, then specify it.

It's a good habit because it helps you (well, it helps me) to come to terms with markup as semantic rather than visual - to assume that a particular tag will look a certain way is to think of XHTML as a visual language, which it isn't.

meow
05-03-2003, 02:29 PM
Hey brothercake! I just reacalled one thing that is deprecated in XHTML 1.0 (that wasn't in HTML4.01). The name attribute for the form element. You win! :o

Catman
05-03-2003, 03:34 PM
I think there is still some use for both <b> and <i>. Take, for example, a references page with entries such as this:

Smith, J.C. 1993. The Incredible Flying Cat. NCTC, Urbana, Illinois.

If you use <em> to mark off the italics, it doesn't really make sense -- putting the title in italics is merely a convention with no special meaning. The reference makes just as much sense without the italics.

So I'd stick with my original statement: If there is indeed semantic meaning, use <strong> and <em> -- if not (that is, if the bold or italics is merely a conventional requirement), then use <b> or <i> or CSS.

And, BTW, I'm not the one who asked, Are the inline text formatting elements depricated in XHTML?

meow
05-03-2003, 03:47 PM
But there almost always is a structural element that can fill the purpose and be styled. In this case I quess CITE would work.

liorean
05-03-2003, 03:58 PM
pardicity3: Yes, the recommended default rendering stylesheet for html4.01 has it. However, no rendering is mandatory for html, not even what is block and what is inline elements.

How about environments that have just one font size, type, weight etc.? How would they distinguish em and strong? Certainly not by using the non existent italics on one and the equally non-existent bold on the other - they would probably resort to colour distinction or even wrapping in some character that makes it stand out - * and / are the typical characters to use to repressent bold and italics, respectively, in such environments.

How about distinction in a screen reader?



As for their styling to stay the same, it probably will for html, xhtml. It will also probably stay that way for xhtml2 and successors, but that has more potential of changing. The more xmlised we get, the less will be implicit and the more we will have to specify ourselves. Of course, if we import the default rendering stylesheet we will get explicit rendering that is equal to the implicit rendering.

<http://www.w3.org/TR/REC-CSS2/sample.html>

(Just as a curiosity, searching the above I found an interesting document here: <http://www.w3.org/People/howcome/p/cascade.html>, a 1994 suggestion for "cascading html stylesheets". I think I know what became of that...)

brothercake
05-03-2003, 04:14 PM
Originally posted by liorean
(Just as a curiosity, searching the above I found an interesting document here: <http://www.w3.org/People/howcome/p/cascade.html>, a 1994 suggestion for "cascading html stylesheets". I think I know what became of that...)
That's fantastic - a real historical perspective. Now if we could use ternary expressions in selectors like it suggests ... that would be way cool. Although now I think about it, CSS3 conditional attribute selectors like [foo*=bar] can be combined with the the :not() pseudo-class to make if() else () conditions in selectors (http://www.codingforums.com/showthread.php?s=&threadid=16367) :)

<cite> is an important tag, and applies to author names and other such fragments, as well as complete citations. The default for that is generally italics as well, but arguably this is wrong since Harvard citations are supposed to be underlned! But I can see why it wouldn't be good to do that - not really a good idea to underline text which isn't a link. As of XHTML there's also a cite attribute for <blockquote> (and <q>?) which takes a URI for the document you're quoting from.

There are other useful ones as well - <address> for contact details, email addresses, phone numbers and so on. <small> for small text - arguably small is not really semantic, but I generally take it to mean negative emphasis, or downplayed with regard to the main content, and I typically use it for "related areas" content and footer information, and such like. <code> for code samples. w3schools has a reference in their XHTML tutorial.

meow
05-04-2003, 03:43 AM
As I understand it CITE is what should be used for things like book and film titles and so on. Style it bold and red if you want. :D

cg9com
05-04-2003, 08:53 AM
*jumps in*

Thanks alot for the input everyone. :)

As you were. :D :D :D