tags:

views:

28

answers:

1

I'm looking for a CSS tag that can provide an id for text. I want to be able to modify the text with javascript, so i need something like:

<texttag id="the_id">the text</texttag>

All the other tags i've tried affect the formatting one way or another. For example it would be used in a sentence, such as:

You live in <texttag id="town_id">Newmarket</texttag>.  Thats a nice town.

And it would display as:

You live in Newmarket. Thats a nice town.

But I would have the ability to modify Newmarket with the id town_id ..

See what i mean? If I use <p> or <div> the text wraps..

+4  A: 

The <span> HTML tag has a display of inline and has no presentational nor semantic meaning attached to it. You can use CSS to apply whatever styles you'd like or script to modify the element's contents.

This sentence has <span id="whatever">text</span>.

To change contents:

docuent.getElementById('whatever').innerHTML('changed text');

To style that specific element:

#whatever { font-weight:bold; }

Also, you may want to read about the difference between block and inline elements. (And an expanded explanation here.) (<p> and <div> are block; <span> is inline.)

josh3736