CSS: Skip underline in part of link
What I really wanted was to have an image "attached" to links, without it getting underlined on hover. Here is a solution I came up with:
<a href="#" style="background:url('pic.png') no-repeat; background-position: left center; padding-left: 20px;">Link</a>
- padding-left is for offsetting the text so it does not overlap the
image. - With background-position you
can move the image to make it better
aligned with the text. - If the image
is higher than the text padding-top
and padding-bottom can be used to
tweak the appearance.
This technique can also be used with CSS sprites like this:
<a href="#" style="background:url('sprites.png') no-repeat; background-position: -16px -16px; padding-left: 32px;">Link</a>
I used a similar technique to use CSS sprites instead of ordinary inline images:
<span style="background:url('sprites.png') no-repeat; background-position: -16px -16px; padding-left: 32px;"></span>
Hope this helps someone
Remove underline from part of a link
The problem is that text-decoration
propagates to descendants:
When specified on or propagated to an inline element, it affects all
the boxes generated by that element, and is further propagated to any
in-flow block-level boxes that split the inline [...]For block containers that establish an inline formatting context, the
decorations are propagated to an anonymous inline element that wraps
all the in-flow inline-level children of the block container.For all other elements it is propagated to any in-flow children.
But there are two exceptions: out-of-flow and atomic inline-level descendants:
Note that text decorations are not propagated to floating and
absolutely positioned descendants, nor to the contents of atomic
inline-level descendants such as inline blocks and inline tables.
Therefore, you can use display: inline-block
on a child to prevent its parent's text-decoration
from affecting it.
a > sup {
display: inline-block; /* Remove parent's text-decoration */
color: red;
}
<a href="http:/example.com//">
Example<sup class='tm'>™</sup>
</a>
Removing underline from a part of the link
Change the :before
pseudo element so that it displays as an inline-block
:
&:before {
content: '\1F847';
color: $green;
padding-right: 8px;
text-decoration: none;
display: inline-block;
}
Removing underline partially from a link
The cleanest option would be to use a custom class for this link
.headerLink {text-decoration:none;}
And then another class for the parts that should be underlined:
.headerLinkAction {text-decoration: underline;}
You may want to update the hover class as well.
Remove blue underline from link
You are not applying text-decoration: none;
to an anchor (.boxhead a
) but to a span element (.boxhead
).
Try this:
.boxhead a {
color: #FFFFFF;
text-decoration: none;
}
How to remove underline from a link in HTML?
Inline version:
<a href="http://yoursite.com/" style="text-decoration:none">yoursite</a>
However remember that you should generally separate the content of your website (which is HTML), from the presentation (which is CSS). Therefore you should generally avoid inline styles.
See John's answer to see equivalent answer using CSS.
Removing an underline from a link in css
Just add text-decoration:none;
to a
tag for #noneall
:
#noneall a{
text-decoration:none;
}
Here is a jsfiddle.
how can i remove underline in link
Use this:
<a style="text-decoration:none" href="http://Example.Microsoft.Com">nonunderlinedhyperlink</a>
Removing underline with href attribute
Add a style with the attribute text-decoration:none;
:
There are a number of different ways of doing this.
Inline style:
<a href="xxx.html" style="text-decoration:none;">goto this link</a>
Inline stylesheet:
<html>
<head>
<style type="text/css">
a {
text-decoration:none;
}
</style>
</head>
<body>
<a href="xxx.html">goto this link</a>
</body>
</html>
External stylesheet:
<html>
<head>
<link rel="Stylesheet" href="stylesheet.css" />
</head>
<body>
<a href="xxx.html">goto this link</a>
</body>
</html>
stylesheet.css:
a {
text-decoration:none;
}
Related Topics
Javafx: Cannot Set Font Size Programmatically After Font Being Set by CSS
Hotlinking My Cascading Style Sheets
Background-Position Not Working with CSS Animation and Linear Gradient
Are CSS Variable Changes Possible Upon a Radio Button's Checked Selector Being Triggered
How to Use Transform-Origin in Conjunction with Svgs
CSS Property Box-Reflect Compatibility
:First-Letter Selector Doesn't Work for Link
How to Fade in Background Image by CSS3 Animation
Bootstrap 5 Off Canvas Missing CSS/Js
Weird Behavior in Firefox with Outlines and Pseudo-Elements
Achieving This Hr Element with CSS Styling - Pseudo Elements
How to Draw a Trapezoid-Like Card
Lighten the Background Colour from Another Class
Codeigniter - Simple Base_Url Question
How to Do Browser Specific Conditional CSS Inside a *.CSS File