I have this HTML:
<ul> <li> <ul> <li> <a href="#"> <span> Test </span> Link </a> </li> </ul> </li> </ul>
And this CSS:
ul li ul li span { text-decoration:none; }
Why would the span inside the anchor still have underline?
In other words: How would I get all the text underlined, except the SPAN. Thanks
By setting the text-decoration to none to remove the underline from anchor tag. Syntax: text-decoration: none; Example 1: This example sets the text-decoration property to none.
Use inline styles to remove the underline of a Link in React, e.g. <Link style={{textDecoration: 'none'}} to="/"> . When the text decoration property is set to none , the underline of the link is removed.
It is perfectly valid (at least by HTML 4.01 and XHTML 1.0 standards) to nest either a <span> inside an <a> or an <a> inside a <span> . i.e. with both HTML 4.01 and XHTML 1.0 doctypes, and both passed validation successfully! Only thing to be aware of is to ensure that you close the tags in the correct order.
You need to target the anchor tag
and not the span tag
so use this
ul li ul li a { text-decoration:none; }
Reason: text-decoration: underline;
is applied to <a>
tag by default browser stylesheet, so if you want to over ride it or if you want that none of the <a>
tags on your website should have an underline than simply use this
a { text-decoration: none; }
Edit: As I read your comment if you want your text to be underline except the text within <span>
than use this
Demo
ul li ul li a { text-decoration:underline; } ul li ul li a span { text-decoration:none; display: inline-block; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With