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

# relative-id

APISummary
## Introduction

Used to set the number of sibling elements in the [relative-layout](/next/guide/ui/layout/relative-layout.md). `-1` and `0` are special values. `-1` is the default value, indicating that the current element will not be considered as the alignment reference standard for sibling elements. Using `0` as an element ID is not allowed, as it will result in unexpected behavior.

## Examples

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

**Entry:** `src/relative-id`
**Bundle:** `dist/relative-id.lynx.bundle`

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

const RelativeId = () => {
  const containerStyle = {
    display: "relative" as const,
  };

  const view1Style = {
    relativeId: "1",
    backgroundColor: "lightgreen",
  };

  const view2Style = {
    relativeRightOf: "1",
    relativeId: "2",
    backgroundColor: "lightblue",
  };

  const view3Style = {
    relativeId: "3",
    relativeCenter: "vertical" as const,
    backgroundColor: "yellow",
  };

  const view4Style = {
    relativeRightOf: "3",
    relativeId: "4",
    relativeCenter: "vertical" as const,
    backgroundColor: "pink",
  };

  const textStyle = {
    fontSize: "50rpx" as const,
    fontWeight: "600" as const,
    textAlign: "center" as const,
  };

  return (
    <view className="container" style={containerStyle}>
      <view style={view1Style}>
        <text style={textStyle}>relative-id: 1</text>
      </view>
      <view style={view2Style}>
        <text style={textStyle}>relative-id: 2</text>
      </view>
      <view style={view3Style}>
        <text style={textStyle}>relative-id: 3</text>
      </view>
      <view style={view4Style}>
        <text style={textStyle}>relative-id: 4</text>
      </view>
    </view>
  );
};

root.render(<RelativeId />);

```

v0.11.0



## Syntax

```css
relative-id: 1;
relative-id: 2;
```

### Values

#### `<number>`

`int` only. the number of the current element. **Default value** is `-1`.

`-1` and `0` are special values. `-1` is the default value, indicating that the current element will not be considered as the alignment reference standard for sibling elements. Using `0` as an element ID is not allowed, as it will result in unexpected behavior.

## Formal definition

| Initial value | `-1` |
| Applies to | relative items |
| Inherited | no |
| Animatable |  |


## Formal syntax

```
relative-id = <integer [1,∞]>
```

## Differences from the Web

- There is no such style in web.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.relative-id`

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| relative-id | Yes (1.4) | Yes (3.4) | Yes (1.4) | Yes (1.4) | Yes (1.4) | No |

**`relative-id`**

Used to set the number of sibling elements in the relative layout.

**Specifications:**

