CSS Properties: How to align the last line of a paragraph element to the right
Solution:
HTML Code:
Explanation:
- This HTML document demonstrates how to align the last line of a paragraph element to the right.
- CSS comments are added to explain each section of the code.
- The p selector styles all paragraph elements.
- text-align: justify; aligns the text of the paragraphs to justify, which causes the lines to spread out to fill the width of the container evenly.
- -moz-text-align-last: right; and text-align-last: right; ensure that the last line of the paragraph is aligned to the right.
- The paragraph contains a lengthy text demonstrating the alignment behavior.
Live Demo :
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.