• Dear WP fans,

    I have a very specific CSS issue that’s driving my absolutely crazy. I can’t seem to get my head around it or maybe it just isn’t possible at all, but there has to be a way to do this:

    I just want to use a link style in my paragrahs with an underline and 2 pixels of padding around it. (When links are hovered, I use the padding with a background color so the links get a nice colored box around them). I also use linked images in my paragraphs which I want to have nice and clean, without any borders, underlines, etc.

    The problem is that when I use linked images in my posts, the images inherrit the link style padding, no matter what I do or how many other classes I add to escape from the link style. I tried making my classes more specific but nothing helps. There has to be a way to do this without having to put in custom classes for all my images?

    I hope someone can help me out with this. I searched and tried a lot but it seems to be a quite specific problem. I’m sure I’m just doing something wrong. The problem seems to start popping up when padding is added to the paragraph links…

    My posts looks like this:

    <div class="entry-content">
    <a href=""><img src=""/></a>
    text
    
    </div>

    And my current CSS (tried lots of things):

    * {
    	margin: 0;
    	padding: 0;
    	border: none;
    	text-decoration: none;
    	font-style: normal;
    	font-weight: normal;
    }
    
    html {
    	height:100%;
    	width: 100%;
    	}
    
    body {
    	background: #FFF;
    	font-style: normal;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: 62.5%;
    	}
    
    form {margin: 0;}
    ul,li,div,h1,h2,h3 {padding: 0; margin: 0;}
    .hidden {display: none;}
    
    img a {
    padding: 0px;
    margin: 0px;
    text-decoration: none;
    border: 0px;
    }
    
    div.entry-content {
    	margin: 0px;
    	padding-bottom: 70px;
    	}
    
    div.entry-content p a, div.entry-content p a:visited {
    	color:#000;
    	font-weight: bold;
    	text-decoration: none;
    	padding:2px;
    	border-bottom: 1px dotted #bbb;
    	}
    
    div.entry-content p a:hover, div.entry-content p a:active {
    	color:#fff;
    	background:#000;
    	border-bottom: 1px dotted #33cccc;
    }
    
    div.entry-content p a img, div.entry-content p a:visited img, div.entry-content p a:hover img, div.entry-content p a:active img {
    border:0px;
    padding:0px; !important
    margin:0px;
    text-decoration: none;
    color:#FFF;
    background:#FFF:
    }

  • The topic ‘styling linked images diffrent from paragraph links with padding’ is closed to new replies.