Saltar al contenido

Propiedad CSS text-align-last

La propiedad CSS text-align-last establece la alineación de la última línea del texto. Es una de las propiedades CSS3.

La propiedad text-align-last establece la alineación para la última línea del contenedor de bloque al que se aplica. Por ejemplo, si un <div> contiene tres párrafos, text-align-last se aplicará solo a la última línea del propio <div>, no a los párrafos individuales dentro de él.

nota

Esta propiedad es más notable cuando se usa text-align: justify y el texto se ajusta a varias líneas. En una sola línea, se comporta idénticamente a text-align.

Valor inicialauto
Se aplica aContenedores de bloque.
HeredableSí.
AnimableNo.
VersiónCSS3
Sintaxis DOMobject.style.textAlignLast = "left";

Compatibilidad con navegadores

NavegadorCompatibilidad
Chrome50+
Edge12+
Firefox49+
Safari10.1+
Opera37+

Sintaxis

Sintaxis de CSS text-align-last

css
text-align-last: auto | left | right | center | justify | start | end | initial | inherit;

Ejemplo de la propiedad text-align-last:

Ejemplo de código CSS text-align-last

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .demo {
        text-align: justify;
        text-align-last: right;
      }
    </style>
  </head>
  <body>
    <h2>Text-align-last property example</h2>
    <h3>text-align-last: right:</h3>
    <div class="demo">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
  </body>
</html>

Resultado

Todos los valores de CSS text-align-last

Ejemplo de la propiedad text-align-last con los valores "start", "justify" y "center":

Ejemplo de todos los valores de CSS text-align-last

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .demo1 {
        text-align: justify;
        text-align-last: start;
      }
      .demo2 {
        text-align: justify;
        text-align-last: center;
      }
      .demo3 {
        text-align: justify;
        text-align-last: justify;
      }
    </style>
  </head>
  <body>
    <h2>Text-align-last property example</h2>
    <h3>Text-align-last: start:</h3>
    <div class="demo1">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
    <h3>Text-align-last: center:</h3>
    <div class="demo2">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
    <h3>Text-align-last: justify:</h3>
    <div class="demo3">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
  </body>
</html>

Ejemplo de la propiedad text-align-last con el valor "end":

Ejemplo de la propiedad text-align-last con el valor "end":

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .demo {
        text-align: justify;
        text-align-last: end;
      }
    </style>
  </head>
  <body>
    <h2>Text-align-last property example</h2>
    <h3>text-align-last: end:</h3>
    <div class="demo">
      <p>
        Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </p>
      <p>
        Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
      </p>
      <p>
        Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book.
      </p>
    </div>
  </body>
</html>

Valores

ValorDescripciónProbarlo
autoUsa el valor de la propiedad text-align. Este es el valor predeterminado.Probarlo »
leftAlinea la última línea a la izquierda.Probarlo »
rightAlinea la última línea a la derecha.Probarlo »
centerAlinea la última línea al centro.Probarlo »
justifyLa última línea se justifica como las demás líneas.Probarlo »
startLa última línea se alinea al principio de la línea. Izquierda si la dirección es de izquierda a derecha y derecha si la dirección es de derecha a izquierda.Probarlo »
endLa última línea se alinea al final de la línea. Derecha si la dirección es de izquierda a derecha, izquierda si la dirección es de derecha a izquierda.Probarlo »
initialHace que la propiedad use su valor predeterminado.Probarlo »
inheritHereda la propiedad de su elemento padre.Probarlo »

Práctica

¿Qué hace la propiedad 'text-align-last' en CSS?

¿Te resulta útil?

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