Saltar al contenido

Propiedad padding-top de CSS

La propiedad padding-top establece el espacio de relleno en la parte superior de un elemento.

INFO

Los valores negativos no son válidos.

INFO

Esta propiedad no afecta a los elementos en línea, como <span>.

Valor inicial0
Se aplica aTodos los elementos, excepto cuando la propiedad display está configurada como table-row-group, table-header-group, table-footer-group, table-row, table-column-group y table-column. También se aplica a ::first-letter.
HeredableNo.
AnimableSí. El espacio de relleno es animable.
VersiónCSS1
Sintaxis DOMobject.style.paddingTop = "10px";

Sintaxis

Sintaxis de la propiedad padding-top de CSS

css
padding-top: length | initial | inherit;

Ejemplo de la propiedad padding-top:

Ejemplo de la propiedad CSS padding-top con valor en píxeles (px)

html
<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
    <style>
      p {
        border: 2px solid #666;
        color: #8ebf42;
        padding-top: 30px;
      }
    </style>
  </head>
  <body>
    <h2>Padding-top property example</h2>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  </body>
</html>

Resultado

CSS padding-top Property

Ejemplo de la propiedad padding-top establecida en "em".

Ejemplo de la propiedad CSS padding-top con valor en "em"

html
<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
    <style>
      p {
        border: 2px solid #666;
        color: #8ebf42;
        padding-top: 4em;
      }
    </style>
  </head>
  <body>
    <h2>Padding-top property example</h2>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  </body>
</html>

Ejemplo de la propiedad padding-top especificada en porcentaje:

Ejemplo de la propiedad CSS padding-top con valor en "%":

html
<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
    <style>
      p {
        border: 2px solid #cccccc;
        color: #8ebf42;
        padding-top: 15%;
      }
    </style>
  </head>
  <body>
    <h2>Padding-top property example</h2>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  </body>
</html>

Valores

ValorDescripciónProbarlo
lengthEstablece el relleno superior en px, pt, cm, etc. El valor predeterminado es 0.Probarlo »
%Establece el relleno superior en % del ancho del elemento contenedor.Probarlo »
initialHace que la propiedad use su valor predeterminado.Probarlo »
inheritHereda la propiedad de su elemento padre.

Práctica

¿Cuál es la función de la propiedad CSS 'padding-top'?

¿Te resulta útil?

Vista previa dual-run — compárala con las rutas Symfony en producción.