In CSS, you can control the alignment of text within an element using the text-align property. Here are the different options for aligning text:
Left Align: Aligns the text to the left edge of the element. This is the default alignment for most elements.
p {
text-align: left;
}
Right Align: Aligns the text to the right edge of the element.
p {
text-align: right;
}
Center Align: Centers the text horizontally within the element.
css
p {
text-align: center;
}
Justify Align: Adjusts the spacing between words in a paragraph so that the text aligns with both the left and right edges of the element. This can create a clean, even left and right margin.
p {
text-align: justify;
}
Start Align: Aligns the text to the start of the element, depending on the language direction. For left-to-right languages like English, it behaves the same as text-align: left. For right-to-left languages like Arabic, it behaves the same as text-align: right.
p {
text-align: start;
}
End Align: Aligns the text to the end of the element, depending on the language direction. For left-to-right languages like English, it behaves the same as text-align: right. For right-to-left languages like Arabic, it behaves the same as text-align: left.
p {
text-align: end;
}
These are the primary options for aligning text horizontally within an element using CSS. By applying the appropriate text-align value to the desired element or selector, you can control the alignment of text and achieve the desired visual presentation.