For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/css/properties/margin-top.md.
Lynx
  • English
  • margin-top

    Introduction

    The margin-top CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, while a negative value places it closer.

    Examples

    Syntax

    /* <length> values */
    margin-top: 0.5em;
    margin-top: 0;
    margin-top: 2rpx;
    
    /* <percentage> value */
    margin-top: 10%;

    Values

    0px

    Default value.

    <length>

    <length> means that the size of the margin as a fixed value.

    <percentage>

    The size of the margin as a percentage, relative to the inline size (width) of the containing block.

    auto

    Selects a suitable margin to use. For example, in certain cases this value can be used to center an element.

    Info

    Currently, Lynx supports using auto in flex, grid and linear children that are not with position:fixed/absolute/sticky.

    Additionally, in linear layout, it only supports using auto on the cross axis. We plan to support using auto on the main axis in the future.

    Formal definition

    Initial value0
    Applies toall elements
    Inheritedno
    Animatableyes
    Percentagesrefer to the width of the containing block

    Formal syntax

    margin-top =
      <length-percentage>  |
      auto                 |
    
    <length-percentage> =
      <length>      |
      <percentage>

    Difference with the Web

    mdn: margin-top

    1. In Lynx, margins will not collapse at any time.
    2. Currently, Lynx supports using auto in flex, grid and linear children that are not with position:fixed/absolute/sticky. Additionally, in linear layout, it only supports using auto on the cross axis. We plan to support using auto on the main axis in the future.

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.