Justifying the Last Line of a DIV: A Comprehensive Approach
Justifying the last line of a DIV can present a challenge, as it typically aligns left by default. However, there exists a method that effectively addresses this issue across browsers, including IE6 and beyond.
This method utilizes a combination of CSS properties:
Additionally, to handle single-line text elements, the following is recommended:
CSS Implementation:
To justify the last line of a DIV, the following CSS rules can be used:
p, h1 { text-align: justify; text-align-last: justify; } p:after, h1:after { content: ""; display: inline-block; width: 100%; }
For one-line text elements, the following is necessary:
h1 { text-align: justify; text-align-last: justify; height: 1em; line-height: 1; } h1:after { content: ""; display: inline-block; width: 100%; }
Detailed Explanation:
This combined approach ensures that the last line of a DIV is justified across multiple browsers, providing a professional and aesthetically pleasing layout.
The above is the detailed content of How Can I Justify the Last Line of a DIV Across All Browsers?. For more information, please follow other related articles on the PHP Chinese website!