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

# vertical-align

APISummary
## Introduction

The vertical-align property sets vertical alignment of inline element.

## Examples

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

**Entry:** `src/vertical-align`
**Bundle:** `dist/vertical-align.lynx.bundle`

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

const VerticalAlign = () => {
  const containerStyle = {
    display: "linear" as const,
  };

  const titleStyle = {
    backgroundColor: "white",
  };

  const orangeContainerStyle = {
    lineHeight: "100px",
    backgroundColor: "orange",
  };

  const tomatoContainerStyle = {
    lineHeight: "100px",
    backgroundColor: "tomato",
  };

  const titleTextStyle = {
    fontSize: "25px",
  };

  const imageStyle = (align: string) => ({
    width: "20px",
    height: "20px",
    verticalAlign: align,
  });

  const textStyle = (align: string) => ({
    verticalAlign: align,
  });

  const viewStyle = (align: string) => ({
    width: "20px",
    height: "20px",
    backgroundColor: "yellow",
    verticalAlign: align,
  });

  return (
    <view className="intro" style={containerStyle} lynx-test-tag="container">
      <text style={titleStyle}>
        set vertical-align: middle,center,top,bottom,text-top,text-bottom,super,baseline,sub
      </text>
      <text style={orangeContainerStyle}>
        <text style={titleTextStyle}>inline-image:</text>

        <image src={playImage} style={imageStyle("middle")}></image>
        <image src={playImage} style={imageStyle("center")}></image>
        <image src={playImage} style={imageStyle("top")}></image>
        <image src={playImage} style={imageStyle("bottom")}></image>
        <image src={playImage} style={imageStyle("text-top")}></image>
        <image src={playImage} style={imageStyle("text-bottom")}></image>
        <image src={playImage} style={imageStyle("super")}></image>
        <image src={playImage} style={imageStyle("baseline")}></image>
        <image src={playImage} style={imageStyle("sub")}></image>
      </text>
      <text style={tomatoContainerStyle}>
        <text style={titleTextStyle}>inline-text:</text>
        <text style={textStyle("middle")}>xx</text>
        <text style={textStyle("center")}>xx</text>
        <text style={textStyle("top")}>xx</text>
        <text style={textStyle("bottom")}>xx</text>
        <text style={textStyle("text-top")}>xx</text>
        <text style={textStyle("text-bottom")}>xx</text>
        <text style={textStyle("super")}>xx</text>
        <text style={textStyle("baseline")}>xx</text>
        <text style={textStyle("sub")}>xx</text>
      </text>
      <text style={orangeContainerStyle}>
        <text style={titleTextStyle}>inline-view</text>
        <view style={viewStyle("middle")}></view>
        <view style={viewStyle("center")}></view>
        <view style={viewStyle("top")}></view>
        <view style={viewStyle("bottom")}></view>
        <view style={viewStyle("text-top")}></view>
        <view style={viewStyle("text-bottom")}></view>
        <view style={viewStyle("super")}></view>
        <view style={viewStyle("baseline")}></view>
        <view style={viewStyle("sub")}></view>
      </text>
    </view>
  );
};

root.render(<VerticalAlign />);

```

v0.11.0



## Syntax

```css
vertical-align: 10px;
vertical-align: 50%;
vertical-align: baseline;
vertical-align: middle;
vertical-align: center;
vertical-align: top;
vertical-align: bottom;
vertical-align: text-top;
vertical-align: text-bottom;
vertical-align: super;
vertical-align: sub;
```

### Values

- `<length>`
  support `length` in Lynx,aligns the baseline of the element to the given length above the initial baseline,a negative value is allowed.

- `<percent>`
  Shift a percentage of the `line-height`,a negative value is allowed.

- `baseline`
  Aligns the baseline of element with the baseline of line.

- `middle`
  Get max x-height of all of text,aligns the middle of element with the position of half max x-height.

- `center`
  Aligns the middle of the element with the middle of line.

- `top`
  Aligns the top of the element with the top of line.

- `bottom`
  Aligns the bottom of the element with the bottom of line.

- `text-top`
  Get max ascent of all of text,aligns the top of element with the position of max ascent.

- `text-bottom`
  Get max descent of all of text,aligns the bottom of element with the position of max descent.

- `super`
  Upward shift 10% of the element's height.

- `sub`
  Downward shift 10% of the element's height.

- default value
  **baseline**

## Formal definition

| Initial value | baseline |
| Applies to | inline-text、inline-image、inline-view |
| Inherited | no |
| Animatable | no |


## Formal syntax

```
<length> | <percent> | baseline | middle | center | top | bottom | text-top | text-bottom | super | sub
```

## Differences from the Web

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

## Notes

- When the'text 'element nests the'view', the default text baseline is aligned to the bottom of the'view ', and the 'vertical-align-baseline' needs to be explicitly set on the'view 'to ensure that the text baseline is aligned to the'view' text baseline.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.vertical-align`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| vertical-align | Yes (2.6) | Yes (3.4) | Yes (2.6) | Yes (2.6) | Yes (2.6) | Yes |

**`vertical-align`**

**Specifications:**

