Paskins Loe Paskins Loe - 5 months ago 13x
HTML Question

css "text-decoration: none" not working

I don't understand why the

text-decoration: none
does not work in the following code. It fails to remove the underline of the word

.button {
color: black;
text-decoration: none;
body {
font-family: 'Roboto', 'Microsoft JhengHei', sans-serif;
font-size: 24px;

<a href="">
<div class="button" id="yes">

As you can see from the example below, the child can override the parent. This is contradictory to the problem above.

.b {
color: black;
.c {
color: yellow;

<div class="b">
<div class="c">


By default the a tag has underline effect (using text-decoration:underline), So to remove this, you must remove from a tag not from its child element.

If you are talking like color values can be overridden from parent to child element but why not text-decoration?

This is because the text-decoration property doesn't inherit the style from its parent element but relies upon its own element.

Check w3c reference.