View Full Version : CSS text-decoration

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).

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

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


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

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?

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.