Aller au contenu

Propriété CSS text-align-last

La propriété CSS text-align-last définit l'alignement de la dernière ligne du texte. Il s'agit de l'une des propriétés CSS3.

La propriété text-align-last définit l'alignement de la dernière ligne du conteneur de bloc auquel elle est appliquée. Par exemple, si un <div> contient trois paragraphes, text-align-last ne s'appliquera qu'à la dernière ligne du <div> lui-même, et non aux paragraphes individuels qu'il contient.

note

Cette propriété est particulièrement visible lorsque text-align: justify est utilisé et que le texte s'enchaîne sur plusieurs lignes. Sur une seule ligne, elle se comporte de manière identique à text-align.

Valeur initialeauto
S'applique àConteneurs de bloc.
HéritéeOui.
AnimableNon.
VersionCSS3
Syntaxe DOMobject.style.textAlignLast = "left";

Compatibilité des navigateurs

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

Syntaxe

Syntaxe CSS de text-align-last

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

Exemple de la propriété text-align-last :

Exemple de code CSS pour 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>

Résultat

Toutes les valeurs de CSS text-align-last

Exemple de la propriété text-align-last avec les valeurs « start », « justify » et « center » :

Exemple de toutes les valeurs 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>

Exemple de la propriété text-align-last avec la valeur « end » :

Exemple de la propriété text-align-last avec la valeur « 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>

Valeurs

ValeurDescriptionTester »
autoUtilise la valeur de la propriété text-align. C'est la valeur par défaut.Tester »
leftAligne la dernière ligne à gauche.Tester »
rightAligne la dernière ligne à droite.Tester »
centerAligne la dernière ligne au centre.Tester »
justifyLa dernière ligne est justifiée comme les autres lignes.Tester »
startLa dernière ligne est alignée au début de la ligne. Gauche si la direction est de gauche à droite et droite si la direction est de droite à gauche.Tester »
endLa dernière ligne est alignée à la fin de la ligne. Droite si la direction est de gauche à droite, gauche si la direction est de droite à gauche.Tester »
initialDéfinit la valeur par défaut de la propriété.Tester »
inheritHérite la propriété de son élément parent.Tester »

Pratique

Que fait la propriété 'text-align-last' en CSS ?

Trouvez-vous cela utile?

Aperçu dual-run — comparez avec les routes Symfony en production.