Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: remove underline from text

Tags:

css

I have the following HTML

<div style="text-decoration: underline;">
    outer text
    <div style="text-decoration: none;">inner text</div>
</div>

Even though I used "none" for "inner text", it is still underlined. Here is the JS fiddle example: http://jsfiddle.net/oj2wj1d6/1/

How can I remove the underline from "inner text"? I have to maintain the same HTML structure without adding any new HTML tags.

like image 380
curious1 Avatar asked Oct 31 '15 21:10

curious1


People also ask

How do I remove underline from text?

Remove underlining To remove single underlining from words and spaces, select the underlined text and press Ctrl+U. To remove other styles of underlining, press Ctrl+U twice.

How do I edit underline in CSS?

In CSS, we will use text-decoration property to style underline. CSS text-decoration-color Property: This property is used to specify the color of decorations (overlines, underlines, and line-throughs) over the text.

What is the CSS code for underline?

The property text-decoration-line is used to underline the text. This property has three values that are overline, underline, or line-through. So, the value underline is used to underline the text in CSS. This value draws the underline beneath the inline text.


1 Answers

This is actually the defined behavior in the spec:

Text decorations draw across descendant elements. This means that it is not possible to disable on a descendant a text decoration that is specified on one of its ancestors.

More details at https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration

like image 91
adilapapaya Avatar answered Oct 01 '22 14:10

adilapapaya