Stop link's :before content from being underlined by rule applied to the link
http://jsfiddle.net/thirtydot/LmvgM/1/
You need to wrap a span
around the text inside the a
:
<div class="box blueb">
<a href="#"><span>Hello</span></a>
</div>
And then change your CSS to this:
.box.blueb a { color: #0098aa; text-decoration: none; }
.box.blueb a:hover > span { text-decoration: underline; }
.box.blueb a:before { content: "> "; }
.box.blueb a:before:hover { text-decoration: none; }
doesn't work because when you set text-decoration: underline
on an element (the a
), you can't then remove it on a descendant (:before
).
How to remove only underline from a:before?
Is it possible to remove this?
Yes, if you change the display style of the inline element from display:inline
(the default) to display:inline-block
:
#test p a:before {
color: #B2B2B2;
content: "► ";
display:inline-block;
}
This is because the CSS specs say:
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 (see section 9.2.1.1). […] For all other elements it is propagated to any in-flow children. 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.
(Emphasis mine.)
Demo: http://jsfiddle.net/r42e5/10/
Thanks to @Oriol for providing the workaround that prompted me to check the specs and see that the workaround is legal.
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 the underline for anchors(links)?
Use CSS. this removes underlines from a
and u
elements:
a, u {
text-decoration: none;
}
Sometimes you need to override other styles for elements, in which case you can use the !important
modifier on your rule:
a {
text-decoration: none !important;
}
Removing the underline from under a visited link
You can't change text-decoration in :visited
Rather set text-decoration:none on anchors and text-decoration:underline on links you want underlined. For example you can use a class to achieve this.
a
{
text-decoration:none;
}
a.underlined
{
text-decoration:underline;
}
Remove underline for a div inside a Link
You may want to use text-decoration
property in the class .link
instead of class .innerdiv
.link { text-decoration: none;}
.link:hover .innerdiv-with-underline { text-decoration: underline;}
<a href="" class="link"> <div> <div class="innerdiv-with-underline">text with underline</div> <div class="innerdiv-without-underline">text</div> </div></a>
Related Topics
How to Write A:Visited in Inline CSS
White-Space: Nowrap Is Not Working in Ie in a Horizontally Scrolling Box
Scale Image with CSS to Both Width and Height to Scale
Change Colour Navbar Header Ionic 2
Make a Div Appear on Hover Over Another Div
Blinking Loading Text in R Shiny
Align Text to The Bottom of a Div
Setting Element Height in Responsive Layout
Hide Div on Mobile Devices, Using CSS
Non 12-Divisible Equal Columns on Bootstrap 4
Css: Fit Relative Positioned Parent to Height of Absolute Positioned Child
Nth-Child to Alternate by 2 Rows
How It Works CSS Font-Weight Values
Unset Width to Revert Back to Inline HTML Attribute "Width=Xx"
CSS 3 Animation "Transform: Scale" on Column Element Doesn't Work on Chrome
Css, Nested Divs & Margins VS. Padding