Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why css "text-decoration" inheritance does not work for "inline-block"? [duplicate]

Tags:

html

css

I wonder - why "text 2" is not underlined?

<div style="text-decoration: underline;">
  <div>text 1</div>
  <div style="display: inline-block;">
    <div>text 2</div>
  </div>
  <div style="display: inline;">
    <div>text 3</div>
  </div>
  <div style="display: block;">
    <div>text 4</div>
  </div>
</div>
like image 605
TSV Avatar asked Apr 07 '26 23:04

TSV


1 Answers

You can find the following sentences on the CSS specification:

Underlines, overlines, and line-throughs are applied only to text (including white space, letter spacing, and word spacing): margins, borders, and padding are skipped. User agents must not render these text decorations on content that is not text. For example, images and inline blocks must not be underlined.
http://www.w3.org/TR/CSS2/text.html#lining-striking-props

like image 122
Sebastian Brosch Avatar answered Apr 09 '26 16:04

Sebastian Brosch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!