> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# width

APISummary
## Introduction

The `width` CSS property specifies the width of an element. By default, the property defines the width of the border area. If [`box-sizing`](/next/api/css/properties/box-sizing.md) is set to `content-box`, however, it instead determines the width of the content area.

The [`min-width`](/next/api/css/properties/min-width.md) and [`max-width`](/next/api/css/properties/max-width.md) properties override `width`.

## Examples

**This is an example below: css-api**

**Entry:** `src/width`
**Bundle:** `dist/width.lynx.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

const Width = () => {
  const containerStyle = {
    display: "linear" as const,
    linearOrientation: "vertical" as const,
  };

  const borderBoxStyle = {
    width: "100px",
    border: "20px solid orange",
  };

  const contentBoxStyle = {
    width: "100px",
    border: "20px solid orange",
    boxSizing: "content-box" as const,
  };

  return (
    <view style={containerStyle}>
      <text style={borderBoxStyle}>
        border-box
      </text>
      <text style={contentBoxStyle}>
        content-box
      </text>
    </view>
  );
};

root.render(<Width />);

```

v0.11.0



## Syntax

```css
/* <length> values */
width: 300px;
width: 25em;

/* <percentage> value */
width: 75%;

/* Keyword values */
width: max-content;
width: fit-content;
width: fit-content(20em);
width: auto;
```

### Values

- `auto`

  **Default value**. lynx will calculate and select a width for the specified element.

- `<length>`

  [`<length>`](/next/api/css/data-type/length.md) defines the width as a distance value.

- `<percentage>`

  Defines the width as a percentage of the [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block)'s width.

- `max-content`

  The intrinsic preferred width.

- `fit-content`

  [`fit-content`](/next/api/css/data-type/fit-content.md) uses the computed size with the available space replaced by the specified argument.

## Formal definition

| Initial value | `auto` |
| Applies to | all elements |
| Inherited | no |
| Animatable | yes |
| Percentages | refer to the width of the containing block |


## Differences from the Web

- By default, the property defines the width of the border area, while Web is `content area`.
- `min-content` is not supported.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.width`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/27-width.json) · [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/width)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| width | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| max-content | Yes (1.6) | Yes (3.4) | Yes (1.6) | Yes (1.6) | Yes (1.6) | Yes |
| fit-content | Yes (2.0) | Yes (3.4) | Yes (2.0) | Yes (2.0) | Yes (2.0) | Yes |
| min-content | No | No | No | No | No | Yes |

**`width`**

**Specifications:**

**`max-content`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/27-width.json)

**`fit-content`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/27-width.json)

**`min-content`**

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/27-width.json)

