mozilla
Your Search Results

    text-decoration

    Summary

    The text-decoration CSS property is used to set the text formatting to underline, overline, line-through or blink. Underline and overline decorations are positioned under the text, line-through over it.

    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. For example, in the markup: <p>This text has <em>some emphasized words</em> in it.</p>, the style rule: p { text-decoration: underline } would cause the entire paragraph to be underlined. The style rule: em { text-decoration: none } would not cause any change; the entire paragraph would still be underlined. However, the rule em { text-decoration: overline } would cause a second decoration to appear on "some emphasized words".

    Note: CSS Text Decoration Level 3 transformed this property as a shorthand for the three new text-decoration-color, text-decoration-line, and text-decoration-style CSS properties. Like for any other shorthand property, it means that it resets their value to their default if not explicitly set in the shorthand.

    • Initial value the concatenation of the initial values of its longhand properties:
      • text-decoration-color: currentColor
      • text-decoration-style: solid
      • text-decoration-line: none
    • Applies to all elements. It also applies to ::first-letter and ::first-line.
    • Inherited no
    • Media visual
    • Computed value as each of the properties of the shorthand:
      • text-decoration-line: as specified
      • text-decoration-style: as specified
      • text-decoration-color: If the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one. The transparent keyword maps to rgba(0,0,0,0).
    • Animatable as each of the properties of the shorthand:
      • text-decoration-color: yes, as a color
      • text-decoration-style: no
      • text-decoration-line: no
    • Canonical order order of appearance in the formal grammar of the values

    Syntax

    /* Keyword values */
    text-decoration: none;                 /* No text decoration */
    text-decoration: underline red;        /* Red underlining */
    text-decoration: underline wavy red;   /* Red wavy underlining */
    
    /* Global values */
    text-decoration: inherit;
    text-decoration: initial;
    text-decoration: unset;
    

    Values

    The text-decoration property is a shorthand and can use the values of each of the three longhand properties: text-decoration-line, text-decoration-color, and text-decoration-style

    Formal syntax

    <'text-decoration-line'> || <'text-decoration-style'> || <'text-decoration-color'>

    Examples

    h1.under {
        text-decoration: underline;
    }
    h1.over {
        text-decoration: overline;
    }
    p.line {
        text-decoration: line-through;
    }
    p.blink {
        text-decoration: blink;
    }
    a.none {
        text-decoration: none;
    }
    p.underover {
        text-decoration: underline overline;
    }
    

    Specifications

    Specification Status Comment
    CSS Text Decoration Level 3
    The definition of 'text-decoration' in that specification.
    Candidate Recommendation Transformed into a shorthand property. Added support for the value of text-decoration-style.
    CSS Level 2 (Revision 1)
    The definition of 'text-decoration' in that specification.
    Recommendation No significant changes.
    CSS Level 1
    The definition of 'text-decoration' in that specification.
    Recommendation Initial specification.

    Browser compatibility

    Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
    Basic support 1.0 (1.7 or earlier) 1.0 3.0 3.5 1.0
    blink value 1.0 (1.7 or earlier)
    Effect removed in 23.0 (23.0)
    (Yes) but without effect (Yes) but without effect 4.0
    Effect removed in 15.0
    (Yes) but without effect
    Shorthand property 6.0 (6.0) (partial)
    36.0 (36.0)
    Not supported Not supported Not supported 7.1 [1]
    Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
    Basic support 1.0 (1.0) (Yes) (Yes) (Yes) (Yes)
    blink value 1.0 (1.7 or earlier)
    Effect removed in 23.0 (23.0)
    (Yes) but without effect (Yes) but without effect 4.0
    Effect removed in 15.0
    (Yes) but without effect
    Shorthand property 6.0 (6.0) (partial)
    36.0 (36.0)
    ? ? ? 8 [1]

    [1] Safari doesn't support text-decoration-style.

    See also