Html padding in one line

CSS padding Property

Set the padding for all four sides of a

element to 35 pixels:

More «Try it Yourself» examples below.

Definition and Usage

An element’s padding is the space between its content and its border.

The padding property is a shorthand property for:

Note: Padding creates extra space within an element, while margin creates extra space around an element.

This property can have from one to four values.

If the padding property has four values:

  • padding:10px 5px 15px 20px;
    • top padding is 10px
    • right padding is 5px
    • bottom padding is 15px
    • left padding is 20px

    If the padding property has three values:

    • padding:10px 5px 15px;
      • top padding is 10px
      • right and left padding are 5px
      • bottom padding is 15px

      If the padding property has two values:

      If the padding property has one value:

      Note: Negative values are not allowed.

      Default value: 0
      Inherited: no
      Animatable: yes, see individual properties. Read about animatable Try it
      Version: CSS1
      JavaScript syntax: object.style.padding=»100px 20px» Try it

      Browser Support

      The numbers in the table specify the first browser version that fully supports the property.

      CSS Syntax

      Property Values

      Value Description Demo
      length Specifies the padding in px, pt, cm, etc. Default value is 0. Read about length units Demo ❯
      % Specifies the padding in percent of the width of the containing element Demo ❯
      initial Sets this property to its default value. Read about initial
      inherit Inherits this property from its parent element. Read about inherit

      More Examples

      Example

      Set the padding for a

      element to 35 pixels for top and bottom, and to 70 pixels for right and left:

      Example

      Set the padding for a

      element to 35 pixels for top, 70 pixels for right and left, and to 50 pixels for bottom:

      Example

      Set the padding for a

      element to 35 pixels for top, 70 pixels for right, 50 pixels for bottom, and to 90 pixels for left:

      Источник

      padding-inline

      The padding-inline CSS shorthand property defines the logical inline start and end padding of an element, which maps to physical padding properties depending on the element’s writing mode, directionality, and text orientation.

      Try it

      Constituent properties

      This property is a shorthand for the following CSS properties:

      Syntax

      /* values */ padding-inline: 10px 20px; /* An absolute length */ padding-inline: 1em 2em; /* relative to the text size */ padding-inline: 10px; /* sets both start and end values */ /* values */ padding-inline: 5% 2%; /* relative to the nearest block container's width */ /* Global values */ padding-inline: inherit; padding-inline: initial; padding-inline: revert; padding-inline: revert-layer; padding-inline: unset; 

      The padding-inline property may be specified with one or two values. If one value is given, it is used as the value for both padding-inline-start and padding-inline-end . If two values are given, the first is used for padding-inline-start and the second for padding-inline-end .

      Values

      The size of the padding as a fixed value. Must be nonnegative.

      The size of the padding as a percentage, relative to the inline size (width in a horizontal language, defined by writing-mode ) of the containing block. Must be nonnegative.

      Description

      Values for this property correspond to the padding-top and padding-bottom , or padding-right , and padding-left property depending on the values defined for writing-mode , direction , and text-orientation .

      Formal definition

      Formal syntax

      Источник

      CSS Padding

      Padding is used to create space around an element’s content, inside of any defined borders.

      CSS Padding

      The CSS padding properties are used to generate space around an element’s content, inside of any defined borders.

      With CSS, you have full control over the padding. There are properties for setting the padding for each side of an element (top, right, bottom, and left).

      Padding — Individual Sides

      CSS has properties for specifying the padding for each side of an element:

      All the padding properties can have the following values:

      • length — specifies a padding in px, pt, cm, etc.
      • % — specifies a padding in % of the width of the containing element
      • inherit — specifies that the padding should be inherited from the parent element

      Note: Negative values are not allowed.

      Example

      Set different padding for all four sides of a element:

      Padding — Shorthand Property

      To shorten the code, it is possible to specify all the padding properties in one property.

      The padding property is a shorthand property for the following individual padding properties:

      If the padding property has four values:

      • padding: 25px 50px 75px 100px;
        • top padding is 25px
        • right padding is 50px
        • bottom padding is 75px
        • left padding is 100px

        Example

        Use the padding shorthand property with four values:

        If the padding property has three values:

        • padding: 25px 50px 75px;
          • top padding is 25px
          • right and left paddings are 50px
          • bottom padding is 75px

          Example

          Use the padding shorthand property with three values:

          If the padding property has two values:

          • padding: 25px 50px;
            • top and bottom paddings are 25px
            • right and left paddings are 50px

            Example

            Use the padding shorthand property with two values:

            If the padding property has one value:

            Example

            Use the padding shorthand property with one value:

            Padding and Element Width

            The CSS width property specifies the width of the element’s content area. The content area is the portion inside the padding, border, and margin of an element (the box model).

            So, if an element has a specified width, the padding added to that element will be added to the total width of the element. This is often an undesirable result.

            Example

            Here, the element is given a width of 300px. However, the actual width of the element will be 350px (300px + 25px of left padding + 25px of right padding):

            To keep the width at 300px, no matter the amount of padding, you can use the box-sizing property. This causes the element to maintain its actual width; if you increase the padding, the available content space will decrease.

            Example

            Use the box-sizing property to keep the width at 300px, no matter the amount of padding:

            More Examples

            Set the left padding
            This example demonstrates how to set the left padding of a

            element.

            Set the right padding
            This example demonstrates how to set the right padding of a

            element.

            Set the top padding
            This example demonstrates how to set the top padding of a

            element.

            Set the bottom padding
            This example demonstrates how to set the bottom padding of a

            element.

            All CSS Padding Properties

            Property Description
            padding A shorthand property for setting all the padding properties in one declaration
            padding-bottom Sets the bottom padding of an element
            padding-left Sets the left padding of an element
            padding-right Sets the right padding of an element
            padding-top Sets the top padding of an element

            Источник

            padding-inline

            padding-inline is a CSS logical shorthand property that combines the padding-inline-start and padding-inline-end properties into a single declaration, creating space around an element’s content in the inline (left and right) direction.

            When we say that padding-inline “creates space around an element’s content” we mean space that provides extra breathing room between the element’s content and the element’s edges. Two boxes each with orange dashed lines and a sentence of content showing padding-inline. The first box is in a horizontal writing mode and the second is in a vertical mode.And that spacing is inside any margins and borders. In other words, it’s the innermost spacing that makes up an element’s Box Model. Showing the Box Model dimensions of an element with values, pulled from DevTools.The padding-inline property may be specified with one or two values. If one value is given, it is used as the value for both padding-inline-start and padding-inline-end . If two values are given, the first is used for padding-inline-start and the second for padding-inline-end .

            The direction depends on the writing mode

            padding-block is a logical property, which means it adapts the writing-mode of a page. So, when we’re in a default horizontal top-to-bottom writing mode ( writing mode: horizontal-tb ), the block direction goes from top to bottom. But when the writing mode changes to a vertical writing mode (e.g. writing-mode: vertical-rl ), the element is rotated turning the block direction into an inline direction where the padding goes from left-to-right (or right-to-left, depending on the exact writing mode). Another way to think about it: padding-block behaves like padding-top and padding-bottom in a default horizontal writing mode, but it behaves like padding-left and padding-right in a vertical writing mode.

            It seems weird to see the syntax of one property reference the syntax of another CSS property right in the documentation, but that’s really what it is. What it’s basically trying to say is that the property accepts the same values as padding-top (up to two times) which follows this syntax:

            • Initial value: 0
            • Applies to: all elements except internal table elements, ruby base containers, and ruby annotation containers
            • Inherited: no
            • Percentages: as for the corresponding physical property
            • Computed value: same as corresponding padding-* properties
            • Animation type: by computed value type

            If you’re familiar with the padding shorthand property, then padding-inline will feel very familiar. The only difference is that it works in two directions instead of four.

            /* Length values */ padding-inline: 20px 40px; padding-inline: 2rem 4rem; padding-inline: 25% 15%; padding-inline: 20px; /* a single value sets both values */ /* Keyword values */ padding-inline: auto; /* Global values */ padding-inline: inherit; padding-inline: initial; padding-inline: unset;

            We said earlier that padding-inline is a shorthand property. That means it combines multiple properties into one declaration, and those included properties are called constituent properties.

            Let’s look specifically at the padding-inline-start and padding-inline-end CSS properties, which makes up the padding-block shorthand. They’re handy as they allow us to define padding in the inline direction, one side at a time.

            padding-inline-start adds padding to the logical “starting” edge of an element in the inline direction. So, if we were working in, say, a default horizontal top-to-bottom writing mode, then the left side of the element is the start and — spoiler alert — the right side of the element is the end.

            But! If we were to change the writing direction to, say, vertical left-to-right, then the starting edge is rotated 90 degrees, which makes the element’s starting edge the top.

            This also applies in a vertical right-to-left writing mode, as illustrated in the example above.

            Writing mode Starting edge
            horizontal-tb Left padding
            vertical-lr Top padding
            vertical-rl Top padding

            padding-inline-end is everything we just looked at with padding-inline-start , only in the opposite direction. So, if the “start” in a horizontal top-to-bottom writing mode is the element’s left side, the “end” is the right side.

            Both vertical left-to-right and vertical right-to-left place the “end” at the bottom edge of an element.

            Writing mode Ending edge
            horizontal-tb Right padding
            vertical-lr Bottom padding
            vertical-rl Bottom padding
            IE Edge Firefox Chrome Safari Opera
            No 87+ 66+ 87+ 14.1 73
            Android Chrome Android Firefox Android Browser iOS Safari Opera Mobile
            Yes Yes 93+ 14.7+ No

            Source: caniuse

            Источник

            Читайте также:  Decrease by one python
Оцените статью