In CSS, I want all links to have a border-bottom: 1px solid property. However, if I have a linked image, it gets the border as well. How can I change the a property if and only if it contains an img element?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try using Descendant Selectors:
If it doesn’t seem to be working, first make sure that the selector is correct (i.e. is referencing the correct element(s)) by putting some crazy statements in that will make it clear which elements are being affected by the selector:
When the selector is working correctly, you can then focus on the statement that isn’t working (don’t forget to remove the crazy statements, though!). It may be being overridden somewhere, so try adding
!importantto the end of the statement:If this works, then you need to carefully examine your CSS code and rearrange your style rules so that you’re not overriding this rule.
If it still doesn’t work, then make sure that you are overriding the correct property with the correct value.