CSS text-decoration / font-style
- type
- property
- applies to
- any element containing text
- inherits
- text-decoration: no (but propagates visually) — font-style: yes
- common values
- text-decoration: none / underline / line-through; font-style: italic / normal
Where it goes
On the text. The most common use is a { text-decoration: none; } to drop link underlines. Then give links some other sign that they are clickable.
Example
a {
text-decoration: none;
}
a:hover,
a:focus {
text-decoration: underline;
}
.old-price {
text-decoration: line-through;
}Common mistakes
- Removing underlines from links in running text and giving them nothing else. Color alone fails for colorblind readers. Keep the underline, or bring it back on hover and focus.
- Using font-style: italic on text that should be <em>, or line-through on text that should be <del>. The look is right but the meaning is lost. Use the tag and let it style itself.
- Trying to remove an underline from a child when the parent is underlined. The line passes down and cannot be removed from inside. Remove it on the parent.