Jump to content

span element with id attribute


greenbelt

Recommended Posts

Sorry for this unnecessary post. I found the answer. Knew it would be something silly. Needed to Save the CSS Style Sheet as well as the HTML document before hitting the refresh button.I've gone through the tutorials many times and also my book "The Complete Reference HTML and XHTML 4th Edition" by Thomas A. Powell ... can't find an answer.I want to try to be XHTML compliant and use the span element for inline formatting. I'm making notes from the tutorials and the book while practicing stuff. I have an idea to highlight terms in yellow, but I don't want to add

<span=background-color:yellow> text text </span>

all over the place. I would rather do something like

<span id="highlight"> text text </span>

and then use a style sheet with

#highlight {background-color:yellow;}

It's not working with Google Chrome or IE. Is my syntax wrong somewhere? Or is this not possible?

Link to comment
Share on other sites

An ID can only be used once in the document. If you have more than one element with the same ID, browsers will probably behave differently from eachother as to how to render it.You should use class instead:

<span class="highlight">

And put this in your stylesheet:

.highlight { background-clor: yellow; }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...