views:

40

answers:

3

Is it possible to select element with specific content?

for example in #footer i have multiple so i can't use #footer > a {}

can i select only that <a> if #footer has <a herf="#header">Top of Page</a>, but not all <a>

Is there any cross-browser way to select like this?

A: 

If I understand you correctly, your selector would be something like this

a[href="yourlink"]

This will select one specific link in your footer that has "yourlink" in the href attribute Is this what you want?

Wai Wong
is it supported in all browser except IE6?
metal-gear-solid
All modern browsers should support this, except for IE6 ofc
Wai Wong
This style of selection by attribute was developed for using CSS with XML documents. In my experience, unless the file (read: the document being styled by this stylesheet) is served up with MIMEtype `application/xml`, selection in this manner will not be recognized as valid.
amphetamachine
It's not working in IE 7 and 8.
metal-gear-solid
A: 

In CSS 2.1 or greater, you can use the Attribute selectors. Most of the popular browsers have already supported this feature, but I.E. 6.0 does not support.

Cary Chow
A: 

CSS2.1 does support selectors such as [att=”val”], in your case [href="#header"], I don't know how many browsers support those yet, though.

But can't you just mark the desired A's with a dedicated class?

inflagranti
no because HTML is not in my control it's generated by server side
metal-gear-solid
The attribute selector is a CSS 2.1 feature not CSS3
Russell Dias
Yeah, true, changed that.
inflagranti