...

View Full Version : CSS properties for *only* a specific appearance of a tag.



KEVaholic00
08-18-2005, 12:49 AM
Hi,

I've seen things like this in CSS elsewhere:


<style type="text/css"><!--
td[width="350"] {
background-color: #FFFFFF;
}
--></style>

The above is just an example, and it might not even be what I'm looking for. But it appears that the above would only change the background color of a table cell that is 350 pixels wide (no other table cells will be changed)?

Is this how this is done? And if not, I'm trying to do something along that concept, somewhat like this:


<style type="text/css"><!--
table[border="2"] td .classname {
color: #FFFFFF;
font-family: verdana;
}
--></style>

If this doesn't make sense, I'll try to reexplain. :)

But if this can be done I'd be ever so grateful. :D

Thanks!
~Kevin

mcdougals4all
08-18-2005, 01:04 AM
This page has a great explanation of CSS selectors, the type you're describing are called attribute selectors. You'll find a link for these about halfway down the page.

http://css.maxdesign.com.au/selectutorial/

KEVaholic00
08-18-2005, 01:12 AM
Thanks a million for the link! :)

I have discovered another problem, however. That page says that Internet Explorer does not support attribute selectors. I looked at the other selectors and none of the ones I could possibly use are supported, either.

Is there another way to go about what I am trying to do?

Thanks!
~Kevin

harbingerOTV
08-18-2005, 01:45 AM
IE doesn't like them yet so could you just do something like (?) :



<style type="text/css">
.table1 {
border: 2px solid #000;
}
.table1 td {
color: #fff;
font-family: verdana;
}
</style>



<table class="table1"><tr><td></td></tr></table>


that should work as intended. Any table that you give the class="table1" to should have black borders and all the td's in the table have white verdana text.

Kurashu
08-18-2005, 01:50 AM
IE doesn't like them

That is well known. That is why they are used to hide some styling from IE.

harbingerOTV
08-18-2005, 01:55 AM
That is well known. That is why they are used to hide some styling from IE.

true that. By the sounds of it though Kevin doesn't want to hide his styling from IE though.

KEVaholic00
08-18-2005, 03:29 AM
Heh, well, it's not that I don't want to do that, it's that I can't.

I'm trying to do it on a MySpace (http://www.myspace.com) profile that really limits what you can do. For instance, it doesn't let you use the pound symbol (#) anywhere, so I can't do anything with ID's. And of course I can't change the HTML that is auto-generated. :/

So, this is why I was wondering if there was a way. Heh. Because the auto-generated HTML lacks a class definition (like I said, I can't use an ID definition).

Thanks anyway. (:

mrruben5
08-18-2005, 11:20 AM
If you really really want css 2 selectors, give IE7 a go.

http://dean.edwards.name/IE7/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum