Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mms

macrumors 6502a
Original poster
Oct 8, 2003
784
0
CA
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.
 
BTW, here is the code I've written so far.
 

Attachments

  • resources.txt
    378 bytes · Views: 184
I'd use a <span> tag with the underline class.

So...

Code:
<p>Here is some general text, but only <span class="underline">these words</span> should be underlined.</p>
 
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?
 
<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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.