CSS Align
The CSS align
property is used to set the horizontal alignment of an element. This property can be applied to various elements such as text, images, tables, and more. There are different values that can be used with the align
property to achieve the desired alignment.
Text Alignment
When it comes to aligning text, you can use the text-align
property in CSS. The following values can be used:
left
: Aligns the text to the leftcenter
: Centers the textright
: Aligns the text to the rightjustify
: Justifies the text
Here is an example of how to center align a paragraph using CSS:
p {
text-align: center;
}
Image Alignment
To align an image, you can use the float
property in CSS. The following values can be used:
left
: Floats the image to the leftright
: Floats the image to the rightnone
: Default value, no floating
Here is an example of how to float an image to the right using CSS:
img {
float: right;
}
Table Alignment
When it comes to aligning tables, you can use the text-align
property on the td
and th
elements. The following values can be used:
left
: Aligns the content to the leftcenter
: Centers the contentright
: Aligns the content to the right
Here is an example of how to center align the content of a table using CSS:
th, td {
text-align: center;
}
With the knowledge of these alignment properties, you can effectively control the layout of your web content to achieve the desired presentation.