css - line-through not working as should -
class .slogan has "text-decoration: line-through;", "span" has "text-decoration: none;" why not canceling it?
header { background: #34abf8; width: 100%; height: 500px; } .slogan { text-align: center; text-transform: uppercase; font-weight: 700; color: white; font-size: 4.5em; text-decoration: line-through; } .slogan span { font-weight: 500; font-size: 0.45em; text-decoration: none; } <header> <div class="slogan"> text underlined. <span>but shouldn't underlined</span> </div> </header>
the spec states clearly:
the 'text-decoration' property on descendant elements cannot have effect on decoration of ancestor.
however, text decorations propagated contents of descendants unless displayed atomic inline-level elements, floated, positioned absolutely.
16.3.1 underlining, overlining, striking, , blinking: 'text-decoration' property
[...] note text decorations not propagated floating , absolutely positioned descendants, nor contents of atomic inline-level descendants such inline blocks , inline tables.
therefore, change display of span inline-block in order prevent <span> element being affected decoration of parent:
header { background: #34abf8; width: 100%; height: 500px; } .slogan { text-align: center; text-transform: uppercase; font-weight: 700; color: white; font-size: 4.5em; text-decoration: line-through; } .slogan span { font-weight: 500; font-size: 0.45em; display: inline-block; } <header> <div class="slogan"> text underlined. <span>but shouldn't underlined</span> </div> </header>
Comments
Post a Comment