Click to See Complete Forum and Search --> : id= vrs class=


cgishack
05-08-2007, 09:01 PM
Hello,
I am trying to write a javascript tab control.
I am using the below css to display the tabs. but right now i have to use
id="tabs". I would like to use class=tabs because i need to id property of the div to be dynamic.
Is there any way i can do this.

current css

#tabs
{
padding: 3px 0;

padding-top:8px;
margin-left: 0;
border-bottom: 1px solid #778;
font:bold 12px Arial;
}

#tabs li
{
list-style: none;
margin: 0;
display:inline;
}

#tabs li a
{
padding: 3px 0.5em;
border: 1px solid #778;
border-bottom: none;
background: #DEE8F5;
text-decoration: none;
}

#tabs li a:link
{
color: #666666;

}
#tabs li a:visited
{
color: #666666;
}

#tabs li a:hover
{
color: #FFF;
background: #1A4D84;
border-color: #000;
}

#tabs li a#current
{
background: white;
color:#000;
border-bottom: 1px solid white;
}


Drew

cgishack
05-08-2007, 09:05 PM
Doh!!
I guess its as simple as .tabs instead of #tabs :)

Nedals
05-08-2007, 09:16 PM
Doh!!
I guess its as simple as .tabs instead of #tabs :)
There is a little more to it than.
#tabs {} is indeed used for an IDs
.tabs {} is used for a class.

BUT.
ID's should only be used once per page.
class may be used many times.

WebJoel
05-09-2007, 12:18 PM
...I am trying to write a javascript tab control....
-Looks as if you writing a "CSS tab control", ??, as I see no javascript whatsoever. Javascript for navigation ("tabs" included) should be avoided. Some user-agents and browsers cannot handle javascript, -some users intentially turn-off javascripting altogether for 'security reasons' and dial-up users with slow modems often turn of *js as well.
I suppose the argument could be made that 'some users turn off CSS', well, -at some point the end-user needs to have some manner of reading a web page and I'd think that more people would intentially turn-off javascript than intentionally turn-off CSS. :)

cgishack
05-09-2007, 01:51 PM
Im using the css for the styling of the tabs, an d the javascript to create a tab control dymanically via code. The code is something like so.

var MyTabControl = new ITabControl(500,500,'parentControl');
MyTabControl.AddTab(MapTab);
MyTabControl.AddTab(SearchTab);
MyTabControl.AddTab(RespotsTab);
MyTabControl.ShowTab(0)