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

# padding

APISummary
## Introduction

Sets the padding area on all four sides of an element at once. An element's padding area is the space between its content and its border.

This property is a shorthand for the following CSS properties: [`padding-top`](/next/api/css/properties/padding-top.md), [`padding-right`](/next/api/css/properties/padding-right.md)、[`padding-bottom`](/next/api/css/properties/padding-bottom.md), [`padding-left`](/next/api/css/properties/padding-left.md).

## Examples

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

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

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

const Padding = () => {
  const scrollViewStyle = {
    flexDirection: "column" as const,
    width: "100%",
    height: "100%",
  };

  const firstBoxStyle = {
    padding: "20px",
  };

  const secondBoxStyle = {
    padding: "20px 5px",
  };

  const thirdBoxStyle = {
    padding: "20px 15px 10px",
  };

  const fourthBoxStyle = {
    padding: "20px 15px 10px 5px",
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical" style={scrollViewStyle}>
      <view className="con">
        <view className="intro" style={firstBoxStyle}>
          <text className="intro2">padding: 20px; All sides</text>
        </view>
      </view>

      <view className="con">
        <view className="intro" style={secondBoxStyle}>
          <text className="intro2">padding: 20px 5px; Top/Bottom | Left/Right</text>
        </view>
      </view>

      <view className="con">
        <view className="intro" style={thirdBoxStyle}>
          <text className="intro2">padding: 20px 15px 10px; Top | Left/Right | Bottom</text>
        </view>
      </view>

      <view className="con">
        <view className="intro" style={fourthBoxStyle}>
          <text className="intro2">padding: 20px 15px 10px 5px; Top | Right | Bottom | Left</text>
        </view>
      </view>
    </scroll-view>
  );
};

root.render(<Padding />);

```

v0.11.0



## Syntax

```css
/* Apply to all four sides */
padding: 1em;

/* top and bottom | left and right */
padding: 5% 10%;

/* top | left and right | bottom */
padding: 1em 2em 2em;

/* top | right | bottom | left */
padding: 5px 1em 0 2em;
```

The padding property may be specified using one, two, three, or four values. Each value is a [`<length>`](/next/api/css/data-type/length.md) or a [`<percentage>`](/next/api/css/data-type/percentage.md). Negative values are invalid.

When one value is specified, it applies the same padding to all four sides.
When two values are specified, the first padding applies to the top and bottom, the second to the left and right.
When three values are specified, the first padding applies to the top, the second to the right and left, the third to the bottom.
When four values are specified, the paddings apply to the top, right, bottom, and left in that order (clockwise).

### Values

#### `0px`

**Default value**.

#### `<length>`

[`<length>`](/next/api/css/data-type/length.md) means that the size of the padding as a fixed value. Must be nonnegative.

#### `<percentage>`

The size of the padding as a percentage, relative to the inline size (width) of the [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block).

## Formal definition

| Initial value | as each of the properties of the shorthand: 
- padding-bottom: 0
- padding-left: 0
- padding-right: 0
- padding-top: 0 |
| Applies to | all elements |
| Inherited | no |
| Animatable |  |
| Percentages | refer to the width of the containing block |


## Formal syntax

```
padding =
  <'padding-top'>{1,4}

<padding-top> =
  <length-percentage [0,∞]>

<length-percentage> =
  <length>      |
  <percentage>
```

## Compatibility

**Compatibility Table**

**Query:** `css.properties.padding`

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

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

**`padding`**

**Specifications:**

