docs.rodeo

MDN Web Docs mirror

column-width

{{CSSRef}} 

The column-width CSS property sets the ideal column width in a multi-column layout. The container will have as many columns as can fit without any of them having a width less than the column-width value. If the width of the container is narrower than the specified value, the single column’s width will be smaller than the declared column width.

{{InteractiveExample("CSS Demo: column-width")}} 

column-width: auto;
column-width: 6rem;
column-width: 120px;
column-width: 18ch;
<section id="default-example">
  <p id="example-element">
    London. Michaelmas term lately over, and the Lord Chancellor sitting in
    Lincoln's Inn Hall. Implacable November weather. As much mud in the streets
    as if the waters had but newly retired from the face of the earth, and it
    would not be wonderful to meet a Megalosaurus, forty feet long or so,
    waddling like an elephantine lizard up Holborn Hill.
  </p>
</section>
#example-element {
  width: 100%;
  columns: auto;
  text-align: left;
}

This property can help you create responsive designs that fit different screen sizes. Especially in the presence of the {{cssxref("column-count")}}  property (which has precedence), you must specify all related length values to achieve an exact column width. In horizontal text these are {{cssxref('width')}} , column-width, {{cssxref('column-gap')}} , and {{cssxref('column-rule-width')}} .

Syntax

/* Keyword value */
column-width: auto;

/* <length> values */
column-width: 60px;
column-width: 15.5em;
column-width: 3.3vw;

/* Global values */
column-width: inherit;
column-width: initial;
column-width: revert;
column-width: revert-layer;
column-width: unset;

The column-width property is specified as one of the values listed below.

Values

Formal definition

{{cssinfo}} 

Formal syntax

{{csssyntax}} 

Examples

Setting column width in pixels

HTML

<p class="content-box">
  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 exercitation ullamcorper suscipit lobortis
  nisl ut aliquip ex ea commodo consequat.
</p>

CSS

.content-box {
  column-width: 100px;
}

Result

{{EmbedLiveSample('Setting_column_width_in_pixels', 'auto', 160)}} 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN