How can I remove the underscore next to the image?

Radu Murzea

Given is the following page (SSCCE, just like we all like it):

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style type="text/css">
    * {
        border:0;
        margin:0;
        padding:0;
    }

    body {
        background:#BCD5E1;
        font:.85em Verdana;
    }

    #flag_panel {
        position:absolute;
        right:15px;
        top:20px;
    }

    #flag_panel img {
        vertical-align:middle;
    }

    #flag_panel .selected_image {
        border:solid 2px #444;
        padding:5px;
    }
    </style>
</head>
<body>
    <div id="flag_panel">
        <a href="#">
            <img src="ro.gif" />
        </a>
        <img class="selected_image" src="us.gif" />
    </div>
</body>
</html>

This HTML file together with the 2 images can be found at the URL: image-problem.zip (1.6 KB)

The expected result is:

expected result

But the actual result is:

actual result

As you can see, there's a little underscore between the 2 images. And I can't figure out why.

I tried this code in Firefox v24 and in Chrome v31. So I'm pretty sure I'm the one missing something.

I noticed that this problem goes away in 2 situations:

  • if the <img class="selected_image"... comes before <a href="#"... (a.k.a. if they're swapped)
  • if the first image is NOT enclosed inside an achor tag (<a>).

The goal of this piece of code is to be able to switch languages between English and Romanian on a site that I own. So one of the images must always have that border around it and the other must always be clickable. But I want to be able to do this without that underscore appearing there (looks ugly / buggy).

Any ideas on how to solve this ? Thanks.

Mr. Alien

Just use the below in your code

#flag_panel a {
   text-decoration: none;
}

Because you are using, so white space is the issue there

<a href="#">
   <img src="#" />
</a>

So that's nothing but default text-decoration


Generally you should use the below snippet in your CSS

a {
   text-decoration: none; /* Gets rid of dirty default underline */
}

Note: The above is an element selector, will select all a elements in the document, but this is a general approach so thought I should share one..


Also, I just went through your profile and I saw that you are not that friendly with HTML and CSS, so here's a tip for you, use CSS Reset stylesheet, it will save your time when dealing with cross browser inconsistencies ... Or if you are not that worried about.. than use the below snippet in your CSS..

* {
   margin: 0;
   padding: 0;
   outline: 0;
}

The above selector simply selects all the elements in your document and gets rid of all the default margin and padding of the elements which are applied by the browser default stylesheet.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I remove the underscore next to the image?

From Dev

How can i <br> two image next to one image?

From Dev

How can I remove a stubborn docker image?

From Dev

How can I remove this image in Excel?

From Dev

How can i remove noise in this binary image and smooth the image -openCV

From Dev

How can I make an image resize dynamically next to a floating sidebar?

From Dev

How can I position an arrow image next to dropdown Bootstrap

From Dev

How can i align an image next to a div horizontally

From Dev

How can I map _ (underscore) in vim?

From Dev

How can i replace space with _ (underscore) in a string?

From Dev

How i can use scss with Underscore theme

From Dev

How can I use underscore functions in Jint

From Dev

How do I change until the next underscore in VIm?

From Dev

How I can remove background color from image using GraphicsMagick?

From Dev

Extra spacing below image, How can i remove it?

From Dev

How can I remove the effects of Vignetting from an image in Python?

From Dev

How can I remove a duplicate image without display:none?

From Dev

How can I remove all white parts from an image in Photoshop?

From Dev

Extra spacing below image, How can i remove it?

From Dev

How can I position the image and then click it and do the remove function jquery?

From Dev

How can I remove an image from a carousel in kivy?

From Dev

how can i remove the selected list item from combobox when i open the combobox next time

From Dev

How can I remove the 'Next' and 'Previous' buttons from multiple forms for iPhone users?

From Dev

In mobile website, the mobile browsers asks me sporadically to open the next webpage on WHICH BROWSER? How can i remove this?

From Dev

How can show text and image in next activity

From Dev

How can I use my own image as prev/next arrow in slick.js?

From Dev

How can I align multi-line text next to an image without it wrapping underneath?

From Dev

How can I create a GIF out of a sequence of PNG files without the previous image appearing on the next frame?

From Dev

How do I align number next to image?

Related Related

  1. 1

    How can I remove the underscore next to the image?

  2. 2

    How can i <br> two image next to one image?

  3. 3

    How can I remove a stubborn docker image?

  4. 4

    How can I remove this image in Excel?

  5. 5

    How can i remove noise in this binary image and smooth the image -openCV

  6. 6

    How can I make an image resize dynamically next to a floating sidebar?

  7. 7

    How can I position an arrow image next to dropdown Bootstrap

  8. 8

    How can i align an image next to a div horizontally

  9. 9

    How can I map _ (underscore) in vim?

  10. 10

    How can i replace space with _ (underscore) in a string?

  11. 11

    How i can use scss with Underscore theme

  12. 12

    How can I use underscore functions in Jint

  13. 13

    How do I change until the next underscore in VIm?

  14. 14

    How I can remove background color from image using GraphicsMagick?

  15. 15

    Extra spacing below image, How can i remove it?

  16. 16

    How can I remove the effects of Vignetting from an image in Python?

  17. 17

    How can I remove a duplicate image without display:none?

  18. 18

    How can I remove all white parts from an image in Photoshop?

  19. 19

    Extra spacing below image, How can i remove it?

  20. 20

    How can I position the image and then click it and do the remove function jquery?

  21. 21

    How can I remove an image from a carousel in kivy?

  22. 22

    how can i remove the selected list item from combobox when i open the combobox next time

  23. 23

    How can I remove the 'Next' and 'Previous' buttons from multiple forms for iPhone users?

  24. 24

    In mobile website, the mobile browsers asks me sporadically to open the next webpage on WHICH BROWSER? How can i remove this?

  25. 25

    How can show text and image in next activity

  26. 26

    How can I use my own image as prev/next arrow in slick.js?

  27. 27

    How can I align multi-line text next to an image without it wrapping underneath?

  28. 28

    How can I create a GIF out of a sequence of PNG files without the previous image appearing on the next frame?

  29. 29

    How do I align number next to image?

HotTag

Archive