Page 1 of 1
Applying styles to only elements within another element
Posted: Sun Oct 12, 2008 10:13 am
by alex.barylski
Code: Select all
#spectra { /* Apply CSS to a DIV */} #spectra a { /* Apply CSS to a anchors within DIV with ID spectra */}
This is how I have it now unfortnately the CSS for anchors is also being applied to other anchors not just those within #spectra DIV???
How do apply styles to only the anchors within my DIV?
Re: Applying styles to only elements within another element
Posted: Sun Oct 12, 2008 10:15 am
by Eran
Your syntax is correct. Make sure: you have correctly closed the spectra div and that the identifier doesn't repeat in the document. Other than that it should work..
Re: Applying styles to only elements within another element
Posted: Sun Oct 12, 2008 10:30 am
by alex.barylski
1. Check
2. Check
But the anchors in a menu are still being styled according to what is only supposed to be applied to anchor's inside <div id="spectra">
I thought I had to do something like:
What is the difference when using the above syntax and what I did earlier?
Re: Applying styles to only elements within another element
Posted: Sun Oct 12, 2008 10:36 am
by Eran
div#spectra > a will apply only to anchor elements which are direct decendants of the #spectra div. IE6 by the way doesn't recognize this format.
You might try to reset the styles at the beginning of the stylesheet, giving default to the a in the document and see if it works.
Code: Select all
a {
color:#000;
text-decoration:underline;
}
Re: Applying styles to only elements within another element
Posted: Sun Oct 12, 2008 11:06 am
by alex.barylski
You might try to reset the styles at the beginning of the stylesheet, giving default to the a in the document and see if it works.
Good idea...thanks
