What\'s the difference between and
,
and
in HTML/XHTML? When should you use
As the others have stated, the difference is that and
hardcode font styles, whereas
and
dictate semantic meaning, with the font style (or speaking browser intonation, or what-have-you) to be determined at the time the text is rendered (or spoken).
You can think of this as a difference between a “physical” font style and a “logical” style, if you will. At some later time, you may wish to change the way and
text are displayed, say, by altering properties in a style sheet to add color and size changes, or even to use different font faces entirely. If you've used “logical” markup instead of hardcoded “physical” markup, then you can simply change the display properties in one place each in your style sheet, and then all of the pages that reference that style sheet get changed automatically, without ever having to edit them.
Pretty slick, huh?
This is also the rationale behind defining sub-styles (referenced using the If you use XHTML, you can even define your own semantic tags, and your style sheet would do the conversions to physical font styles and layouts for you.style=
property in text tags) for paragraphs, table cells, header text, captions, etc., and using