Different Styles on Single line CSS and XHTML-strict

Relli

Weaksauce
Joined
Jan 16, 2001
Messages
98
I'm trying to use strict XHTML and CSS to build a website. I need to have text that is bold, underlined, and normal in the same line. In old html I would have done it like this:

<b>Some Bold Text</b>&nbsp;<u>Some Underlined Text</u>&nbsp;Some Regular Text

I created a CSS class that bold's the text and another that underlines the text, but all the html tags I know of (such as <div> or <p>) insert new lines before and/or after.

I could easily do it if I knew of a tag that didn't do anything, like <font>. Then just do something like:
<font class="bold">Bold Text</font><font class="under">Underlined Text</font>

What is a good way to handle this?
 
The <strong> and <em> tags are what you are looking for. Look at their default behavior, and if you don't like it, override that behavior in your CSS.
 
Thanks, for some reason I didn't think <strong> and <em> were in the strict DTD.
 
<span> is the in-line generic style tag you were wanting to use.

As noted, though -- there's no reason to define <span class="bold"> when <strong> is there and can generally be styled w/o a class/id specification.

Also, a <span> is just a <div style="display:inline"> and a <div> is just a <span style="display:block">. Random trivia.
 
Even more thanks. That is more what I was looking for. It seems better to use <span> to underline instead of overriding <em>. Using <em> did work though, but it seems like better style to use <span>

Thanks for the display:block and display:inline. I didn't know what those did really, even though I had seen them.
 
Back
Top