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

# max-height

APISummary
## Introduction

To specify max height of a view. It prevents the applied value of [`height`](/next/api/css/properties/height.md) becoming larger than the specified value of `max-height`.
The priority of `max-height` is higher than [`height`](/next/api/css/properties/height.md) and [`min-height`](/next/api/css/properties/min-height.md).

## Examples

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

**Entry:** `src/max-height`
**Bundle:** `dist/max-height.lynx.bundle`

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

const MaxHeight = () => {
  const containerStyle = {
    display: "linear" as const,
    linearDirection: "row" as const,
  };

  const firstBoxStyle = {
    height: "300px",
    backgroundColor: "green",
    width: "100px",
  };

  const secondBoxStyle = {
    height: "400px",
    backgroundColor: "yellow",
    width: "100px",
    maxHeight: "300px",
  };

  const thirdBoxStyle = {
    height: "300px",
    backgroundColor: "blue",
    width: "100px",
    minHeight: "400px",
    maxHeight: "200px",
  };

  return (
    <view className="intro" style={containerStyle}>
      <view style={firstBoxStyle}>
        <text>height: 300px</text>
      </view>
      <view style={secondBoxStyle}>
        <text>height: 400px; max-height: 300px</text>
      </view>
      <view style={thirdBoxStyle}>
        <text>height: 300px; min-height: 400px; max-height: 200px</text>
      </view>
    </view>
  );
};

root.render(<MaxHeight />);

```

v0.11.0



## Syntax

```css
/* <length> */
max-height: 120px;
max-height: 10em;

/* <percentage> */
max-height: 75%;
```

### Values

#### `<length>`

[`<length>`](/next/api/css/data-type/length.md) Defines the max-height as an absolute value.

#### `<percentage>`

Defines the `max-height` as a percentage of the containing block's height.

## Formal definition

| Initial value | no limit |
| Applies to | all elements |
| Inherited | no |
| Animatable |  |
| Percentages | The percentage is calculated with respect to the height of the generated box's containing block |


## Formal syntax

```css
/* <length> */
max-height: 120px;
max-height: 10em;

/* <percentage> */
max-height: 75%;
```

## Differences from the Web

[mdn:max-height](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height)

1. In Lynx, the priority of `max-height` is higher than `height` and `min-height`. While in Web, `max-height` overrides `height`, but `min-height` overrides `max-height`.
2. In Lynx, if `max-height` is specified smaller than `min-height`, `min-height` will be ignored.
3. `none`, `max-content`, `min-content`, `fit-content`, `min-content` are not supported.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.max-height`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| max-height | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`max-height`**

sets the maximum height of an element.

**Specifications:**

