Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

class + title

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
Can you set a title for a class so when applied to an object it would display a message like the alt tag?
 
No, remember that CSS is only for defining layout and appearance, not content. Displaying a title would be content. Going from there, you would have to add the title attribute to the tag you want the title to display at, e.g.:
Code:
<img title=&quot;Look at me, I'm a title!&quot;>

:)

Take Care,
Mike
 
However, using the DOM and javascript, you can set the title and alt...

function setTitle(){
allTDs = document.getElementsByTagName(&quot;td&quot;)
for (x=0; x<allTDs.length; x++){
if (allTDs[x].className == &quot;myClass&quot;){
allTDs[x].title = &quot;This is in the class&quot;
}
}
}

<body onLoad=&quot;setTitle()&quot;>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top