mozilla

Revision 291242 of text-indent

  • Revision slug: CSS/text-indent
  • Revision title: text-indent
  • Revision id: 291242
  • Created:
  • Creator: bfrohs
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The text-indent CSS property specifies how much horizontal space should be left before the beginning of the first line of the text content of an element. Horizontal spacing is with respect to the left (or right, for right-to-left layout) edge of the containing block element's box.

  • {{ Xref_cssinitial() }}: 0
  • Applies to: block and inline-block elements, table cells
  • {{ Xref_cssinherited() }}: yes
  • Percentages: refer to width of containing block
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: the percentage as specified or the absolute length

Syntax

text-indent:  <length> | <percentage> && [ hanging || each-line ]

Values

<length>
Indentation is specified as fixed {{ Xref_csslength() }}. Negative Values are allowed. See {{ Xref_csslength() }} values for possible units.
<percentage>
Indentation is a {{ Xref_csspercentage() }} of the containing block width.
each-line {{ experimental_inline() }}
Indentation affects the first line of the block container as well as each line after a forced line break, but does not affect lines after a soft wrap break.
hanging {{ experimental_inline() }}
Inverts which lines are indented

Examples

p { text-indent: 2em } 

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Specifications

Specification Status Comment
CSS Text Level 3 {{ Spec2('CSS3 Text') }} Added the hanging and each-line keywords
CSS 2.1 {{ Spec2('CSS2.1') }} The behavior with display: inline-block and anonymous block box has been explicitly defined.
CSS 1 {{ Spec2('CSS1') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{ CompatGeckoDesktop("1.0") }} 1.0 3.0 3.5 1.0 (85)
hanging {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
each-line {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatGeckoMobile("1.9.2") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
hanging {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
each-line {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

See also

  • {{ CSS_Reference:Text() }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>text-indent</code> CSS property specifies how much horizontal space should be left before the beginning of the first line of the text content of an element. Horizontal spacing is with respect to the left (or right, for right-to-left layout) edge of the containing block element's box.</p>
<ul class="cssprop">
  <li><dfn>{{ Xref_cssinitial() }}:</dfn> <code>0</code></li>
  <li><dfn>Applies to:</dfn> block and inline-block elements, table cells</li>
  <li><dfn>{{ Xref_cssinherited() }}:</dfn> yes</li>
  <li><dfn>Percentages:</dfn> refer to width of containing block</li>
  <li><dfn>Media:</dfn> <code> {{ Xref_cssvisual() }}</code></li>
  <li><dfn>{{ Xref_csscomputed() }}:</dfn> the percentage as specified or the absolute length</li>
</ul>
<h2 id="Syntax">Syntax</h2>
<pre>
text-indent:  &lt;length&gt; | &lt;percentage&gt; &amp;&amp; [ hanging || each-line ]
</pre>
<h3 id="Values">Values</h3>
<dl>
  <dt>
    &lt;length&gt;</dt>
  <dd>
    Indentation is specified as fixed {{ Xref_csslength() }}. Negative Values are allowed. See {{ Xref_csslength() }} values for possible units.</dd>
  <dt>
    &lt;percentage&gt;</dt>
  <dd>
    Indentation is a {{ Xref_csspercentage() }} of the containing block width.</dd>
  <dt>
    <code>each-line</code> {{ experimental_inline() }}</dt>
  <dd>
        Indentation affects the first line of the block container as well as each line after a <i>forced line break</i>, but does not affect lines after a <i>soft wrap break</i>. </dd>
  <dt>
    <code>hanging</code> {{ experimental_inline() }}</dt>
  <dd>
    Inverts which lines are indented</dd>
  <br />
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush: css">
p { text-indent: 2em } 
</pre>
<p style="text-indent:2em; max-width:40em; background:gold">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="external" href="http://dev.w3.org/csswg/css3-text/#text-indent" title="http://dev.w3.org/csswg/css3-text/#text-indent">CSS Text Level 3</a></td>
      <td>{{ Spec2('CSS3 Text') }}</td>
      <td>Added the <code>hanging</code> and <code>each-line</code> keywords</td>
    </tr>
    <tr>
      <td><a class="external" href="http://www.w3.org/TR/CSS21/text.html#indentation-prop" title="http://www.w3.org/TR/CSS21/text.html#indentation-prop">CSS 2.1</a></td>
      <td>{{ Spec2('CSS2.1') }}</td>
      <td>The behavior with <code>display: inline-block</code> and anonymous block box has been explicitly defined.</td>
    </tr>
    <tr>
      <td><a class="external" href="http://www.w3.org/TR/REC-CSS1/#text-indent" title="http://www.w3.org/TR/REC-CSS1/#text-indent">CSS 1</a></td>
      <td>{{ Spec2('CSS1') }}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Firefox (Gecko)</th>
        <th>Chrome</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatGeckoDesktop("1.0") }}</td>
        <td>1.0</td>
        <td>3.0</td>
        <td>3.5</td>
        <td>1.0 (85)</td>
      </tr>
      <tr>
        <td><code>hanging</code></td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
      <tr>
        <td><code>each-line</code></td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>Android</th>
        <th>IE&nbsp;Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatGeckoMobile("1.9.2") }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
      </tr>
      <tr>
        <td><code>hanging</code></td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
      <tr>
        <td><code>each-line</code></td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{ CSS_Reference:Text() }}</li>
</ul>
Revert to this revision