right

  • Revision slug: CSS/right
  • Revision title: right
  • Revision id: 25252
  • Created:
  • Creator: McGurk
  • Is current revision? No
  • Comment Updated browser compatibility; 13 words added, 23 words removed

Revision Content

{{ CSSRef() }}

Summary

The right CSS property specifies part of the position of positioned elements.

For absolutely positioned elements (those with {{ Cssxref("position") }}: absolute or position: fixed), it specifies the distance between the right margin edge of the element and the right edge of its containing block.

The right property has no effect on non-positioned elements.

When both the right CSS property and the {{ cssxref("left") }} CSS property are defined, the position of the element is overspecified. In that case, the {{ cssxref("left") }} value has precedence when the container is left-to-right (that is that the right computed value is set to -left), and the right value has precedence when the container is right-to-left (that is that the {{ cssxref("left") }} computed value is set to -right).

  • {{ Xref_cssinitial() }}: {{ Cssxref("auto") }}
  • Applies to: positioned elements
  • {{ Xref_cssinherited() }}: no
  • Percentages: refer to width of containing block
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: absolute length, percentage, or auto

Syntax

right: <length> | <percentage> | auto | inherit ;

Values

{{ Xref_csslength() }} 
A length, can be negative, zero, or positive.
{{ Xref_csspercentage() }} 
A percentage of the containing block's width.

Examples

{{ CSSLiveSample("css-positioning.html") }}

#example_3 {
  width: 600px;
  height: 400px;
  background-color: #FFC7E4;
  position: relative;
  top: 20px;
  left: 20px;
}

#example_4 {
  width:200px;
  height:200px;
  background-color: #FFD7C2;
  position:absolute;
  bottom:10px;
  right: 20px;
}

Notes

Specifications

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ CompatGeckoDesktop("1") }} 5.5 5.0 1.0
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1.0 {{ CompatGeckoMobile("1") }} 6.0 6.0 1.0

See also

{{ Cssxref("position") }}, {{ Cssxref("top") }}, {{ Cssxref("bottom") }}, {{ Cssxref("left") }}

{{ languages( { "es": "es/CSS/right", "de": "de/CSS/right" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3 name="Summary">Summary</h3>
<p>The <code>right</code> <a href="/en/CSS" title="CSS">CSS</a> property specifies part of the position of positioned elements.</p>
<p>For absolutely positioned elements (those with {{ Cssxref("position") }}<code>: absolute</code> or <code>position: fixed</code>), it specifies the distance between the right margin edge of the element and the right edge of its containing block.</p>
<p>The <code>right</code> property has no effect on non-positioned elements.</p>
<p>When both the <code>right</code> CSS property and the {{ cssxref("left") }} CSS property are defined, the position of the element is<em> overspecified</em>. In that case, the {{ cssxref("left") }} value has precedence when the container is left-to-right (that is that the <code>right</code> computed value is set to <code>-left</code>), and the <code>right</code> value has precedence when the container is right-to-left (that is that the {{ cssxref("left") }} computed value is set to <code>-right</code>).</p>
<ul> <li>{{ Xref_cssinitial() }}: {{ Cssxref("auto") }}</li> <li>Applies to: <a href="/en/CSS/position" title="en/CSS/position">positioned elements</a></li> <li>{{ Xref_cssinherited() }}: no</li> <li>Percentages: refer to width of containing block</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: absolute length, percentage, or auto</li>
</ul>
<h3 name="Syntax">Syntax</h3>
<pre class="eval">right: &lt;length&gt; | &lt;percentage&gt; | auto | inherit ;
</pre>
<h3 name="Values">Values</h3>
<dl> <dt>{{ Xref_csslength() }} </dt> <dd>A length, can be negative, zero, or positive.</dd> <dt>{{ Xref_csspercentage() }} </dt> <dd>A percentage of the containing block's width.</dd>
</dl>
<h3 name="Examples">Examples</h3>
<p>{{ CSSLiveSample("css-positioning.html") }}</p>
<pre class="eval">#example_3 {
  width: 600px;
  height: 400px;
  background-color: #FFC7E4;
  position: relative;
  top: 20px;
  left: 20px;
}

#example_4 {
  width:200px;
  height:200px;
  background-color: #FFD7C2;
  position:absolute;
  bottom:10px;
  right: 20px;
}</pre>
<h3 name="Notes">Notes</h3>
<h3 name="Specifications">Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/visuren.html#propdef-right">CSS 2.1</a></li>
</ul>
<h2 name="Browser_Compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>1.0</td> <td>{{ CompatGeckoDesktop("1") }}</td> <td>5.5</td> <td>5.0</td> <td>1.0</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>1.0</td> <td>{{ CompatGeckoMobile("1") }}</td> <td>6.0</td> <td>6.0</td> <td>1.0</td> </tr> </tbody> </table>
</div><h3 name="See_also">See also</h3>
<p>{{ Cssxref("position") }}, {{ Cssxref("top") }}, {{ Cssxref("bottom") }}, {{ Cssxref("left") }}</p>
<p>{{ languages( { "es": "es/CSS/right", "de": "de/CSS/right" } ) }}</p>
Revert to this revision