Skip to content

Instantly share code, notes, and snippets.

@juanm55
Created October 29, 2011 15:06
Show Gist options
  • Save juanm55/1324560 to your computer and use it in GitHub Desktop.
Save juanm55/1324560 to your computer and use it in GitHub Desktop.
HTML links with images that aren't underlined
/* the idea here is to create a link with an image AND some text,,,, but ONLY the text gets underlined*/
/* with this setup and CSS it is not possible to take out the underline of the img element (since it is an in-line element)*/
<a href=#><img src="path/to/file" /> some text</a>
/* Because 'a' styling is supposed to have text-decoration:underline; and that affects the image too....
even with:
a img {text-decoration:none;}
*/
so the hack comes here.... CSS this: .imagelink{text-decoration:none}
and in HTML: <a href=# class="imagelink"><img src="path/to/file" /> <u>some text</u></a>
where we can see how useful the <u> is....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment