PDA

View Full Version : CSS text-decoration


mms
Jan 23, 2004, 07:28 PM
In CSS, is there a way to format only part of the text on a line? Specifically, I would like to make one part of a line underlined and another part normal text. I would like to refrain from using <u>, which is depreciated.

What I am trying to do is rewrite this page (http://prod031.sandi.net/muirlands/SCIENCE%20FAIR%20RESOURCES%202.asp).

mms
Jan 23, 2004, 07:29 PM
BTW, here is the code I've written so far.

Rower_CPU
Jan 23, 2004, 09:27 PM
I'd use a <span> tag with the underline class.

So...

<p>Here is some general text, but only <span class="underline">these words</span> should be underlined.</p>

brianellisrules
Jan 24, 2004, 01:04 AM
What's the deal with <span> tags? I don't use them because it seems like they're usually hit and miss. <div> tags seem to be much more consistent.


Or maybe I'm using them wrong. That's probably it. Can <span> tags only be used within <p> tags or something?

Rower_CPU
Jan 24, 2004, 12:30 PM
<div> tags are block-level elements, while <span> tags are inline. So <div>s work best for layout and <span>s for inline styles within a block-level element, such as a <p>, <li>, <h1>, etc.