Reputation: 117
<div id="gallerywrapper">
<img src="ECC1.png"> <!--1-->
<img src="ECC2.png"> <!--2-->
</div>
CSS:
#gallerywrapper img{
border: 2px;
}
Why won't the css selector apply the border attributes to the pictures? Am I using the wrong selector?
Upvotes: 0
Views: 208
Reputation: 8660
Your selector is perfectly fine, what is wrong is the lack of 'style' for the border.
Something like border: 2px solid;
would work just fine. This will set all four sides to be 'solid' at 2px thick; opposed to the default 'none' at 'medium', what ever 'medium' is.
Just as a side note or point of reference, your current selector is 'any img tag that is a descendent of a #gallerywrapper', if you swap to #gallerywrapper > img
you will get only the direct children. In other words, buy adding the >
you could have say a <p>
with an image in it would not get a border, and as it is not a direct child. Either way works given the HTML the OP posted, and neither is 'bad'.
Upvotes: 3
Reputation: 3065
use this
#gallerywrapper > img{ border: 2px solid; }
and it will work.
UPDATED
As OP asked clearly that he don't know why its not working and needed solution so i gave him final solution(No More chit chat). He did not ask for more details so i did not provide. but here i go..
User did not define any style for border which is must..Read more here
Without Border-style, no border will show..that's why that selector wasn't working.And in general m using the way i provide so i provided that solution so i don't think its wrong or confusing.. But...Nothing..
Upvotes: 0