I have 3 DIV Elements on a website and this CSS:
#box-left, #box-middle, #box-right a {
text-decoration:none;
color:#000000;
}
it only seems to be working on the #box-right
element though.
Any ideas?
The HTML id attribute is used to specify a unique id for an HTML element. You cannot have more than one element with the same id in an HTML document.
The second id or any other id after the first one will just be ignored by the browser. So having multiple ids for a div is not only pointless but is also incorrect HTML. If you need multiple tags for an HTML element, just use the class attribute. You can have as many classes as you want.
The major difference is that IDs can only be applied once per page, while classes can be used as many times on a page as needed. “ if you want to apply same css to multiple html elements, use class. just define a class in css, write all stylings and then give that class to all elements you want to style same.
You have to put
#box-left a, #box-middle a, #box-right a {
text-decoration:none;
color:#000000;
}
Each value on the comma separator list is a selector on its own, it is not combined with the next elements:
#foo, .class p, #bar p:first-child a {
something;
}
is equivalent to
#foo {
something;
}
.class p {
something;
}
#bar p:first-child a {
something;
}
Try
#box-left a,
#box-middle a,
#box-right a {
text-decoration:none;
color:#000000;
}
because it is for all div's anchor tag.
It is better to give a anchor tag class and apply that class directly.
You haven't put the element a to your selector, to understand well your css if you have to conatenate more than a div or a class consider to make a new paragraph to understand well your code like this:
#box-left a,
#box-middle a,
#box-right a {
text-decoration:none;
color:#000000;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With