How do I remove the underline from an image wrapped in an anchor?

Tags: css

Problem :

Anyhow, I have a problem. A tiny problem I suppose, but one that's bugging me. I updated the CSS for my anchors on my blog, so that they were underlined with a border. Problem now is all my images that were linked are underlined, and it looks wrong.

So I assume the only way to fix this is to apply a CSS class to all the images inside anchors so that they have border: none;. I don't know how to do this though. Anyone willing to explain if this is even possible? Thanks in advance.

Solution :

Try this:

<style type="text/css">
a img { text-decoration: none } // Images within 

However, this is awfully general and if your anchors have padding, it won't work entirely, there may be residue underlining to the right and left of your image.

It would be better to turn underlining for links off in general, define a CSS class for your anchors, and turn underlining on in that class:

a { text-decoration: none }
a.my_anchor_class { text-decoration: underline }

    CSS Howto..

    How can I separate and make a menu with these links in CSS without using unordered lists [closed]

    how to apply css property to my first div class only

    How to make my words not go under my picture in css

    How to use CSS function instead of LESS function?

    Wordpress how to make sticky navigation menu / make the menu stick to the top all the time?

    How to debug(make page look like in Firefox) CSS in IE? [duplicate]

    how to compute Facebook graph api cover offset_y to pixel?

    How to reapply .css file after UpdatePanel asynchronous call completed

    How do I align my navbar so it's permanently in the middle of my white box (without padding etc)?

    How To Apply CSS rule to Classes with Specific Keywords Inside Them?

    How to stop these two divs/navbars from overlapping in Bootstrap

    How to index star rating in google?

    How can I make a table column width somewhat similar automatically?

    How to trigger css :hover event on PageLoad

    How to add styles to wordpress default menu

    How to not apply a webpage's CSS on the div I am inserting into it via content scripts?

    How to return WebElement having particular CSS property using JavascriptExecutor?

    CSS: how to add a style to everything, unless it is defined

    How to script CSS to achieve hide/appear effect based on hover

    How can I convince Firefox to redraw CSS Pseudo-elements?

    image shows ui-button over the button image

    Asp.Net how to apply a css style to all the control of it's kind

    CSS: how to position element in lower right?

    How to create CSS styled dom element inside Google Maps InfoWindow?

    How to properly align icon and text in a table?

    how to make observable a css class with knockout js

    How do I get responsive images to stay equivalent heights as they scale?

    How to make sure the users see the new logo?

    Fonts wont change and id height wont show

    Inline blocks somehow don't get displayed in a straight line [duplicate]