Back to Content

border-right-width

files/en-us/web/css/reference/properties/border-right-width/index.md

latest2.4 KB
Original Source

The border-right-width CSS property sets the width of the right border of an element.

{{InteractiveExample("CSS Demo: border-right-width")}}

css
border-right-width: thick;
css
border-right-width: 2em;
css
border-right-width: 4px;
css
border-right-width: 2ex;
css
border-right-width: 0;
html
<section class="default-example" id="default-example">
  <div class="transition-all" id="example-element">
    This is a box with a border around it.
  </div>
</section>
css
#example-element {
  background-color: palegreen;
  color: black;
  border: 0 solid crimson;
  padding: 0.75em;
  width: 80%;
  height: 100px;
}

Syntax

css
/* Keyword values */
border-right-width: thin;
border-right-width: medium;
border-right-width: thick;

/* <length> values */
border-right-width: 10em;
border-right-width: 3vmax;
border-right-width: 6px;

/* Global keywords */
border-right-width: inherit;
border-right-width: initial;
border-right-width: revert;
border-right-width: revert-layer;
border-right-width: unset;

Values

  • <line-width>
    • : Defines the width of the border, either as an explicit nonnegative {{cssxref("<length>")}} or a keyword. If it's a keyword, it must be one of the following values:
      • thin
        • Same as 1px.
      • medium
        • Same as 3px.
      • thick
        • Same as 5px.

Formal definition

{{CSSInfo}}

Formal syntax

{{csssyntax}}

Examples

Comparing border widths

HTML

html
<div>Element 1</div>
<div>Element 2</div>

CSS

css
div {
  border: 1px solid red;
  margin: 1em 0;
}

div:nth-child(1) {
  border-right-width: thick;
}
div:nth-child(2) {
  border-right-width: 2em;
}

Result

{{EmbedLiveSample('Comparing_border_widths', '100%')}}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • The other border-width-related CSS properties: {{Cssxref("border-bottom-width")}}, {{Cssxref("border-left-width")}}, {{Cssxref("border-top-width")}}, and {{Cssxref("border-width")}}.
  • The other border-right-related CSS properties: {{Cssxref("border")}}, {{Cssxref("border-right")}}, {{Cssxref("border-right-style")}}, and {{Cssxref("border-right-color")}}.