HTML CSS SQL Meta tag Generator ScrollBar design Generator Encode Decode images

CSS Basics

Introduction Syntax Selectors Attribute Selectors Specificity Combinators !important Comments Colors

CSS Need to Know

Box Model Pseudo-class Pseudo-element Inline-block Math Functions Max and Min Opacity Outline Overflow Z-index Float

Most used

Align Backgrounds Borders Text Units Padding Margins Position Tables Display Fonts Lists Height and Width

CSS Reference

CSS Properties reference CSS Pseudo-Classes reference CSS Pseudo-Elements reference CSS Selector reference

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:

Here is an example of how to center align a paragraph using CSS:

p {
  text-align: center;
}
Result:

Align left Text


Align right Text


Align center Text


Align justify Text.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Image Alignment

To align an image, you can use the float property in CSS. The following values can be used:

Here is an example of how to float an image to the right using CSS:

img {
  float: right;
}
Result:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

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:

Here is an example of how to center align the content of a table using CSS:

th, td {
  text-align: center;
}
Result:
Header 1 Header 2
Row 1, Cell 1 Row 1, Cell 2
Row 2, Cell 1 Row 2, Cell 2

With the knowledge of these alignment properties, you can effectively control the layout of your web content to achieve the desired presentation.