In the HTML and CSS world, it’s all about the layout structure and the distribution of elements. We usually use HTML to define the markup and structure, while CSS helps us handle the styling and alignment of elements.

In this post we are going to learn a little bit about the different ways we can center HTML elements and handle vertical alignment with CSS.

First we going to learn how to align text with CSS.

Next, we will cover how to align a div and any other elements.

And finally we will learn how we can put text and a div together within a container.

How to center text

There are many way to center text using CSS.

Using the Float property

Float is an easy way to align text.

To place the text on the right side of the layout, we can simply use right as a value for float.

To place the text on the left side, we use left, like float:left. Look at the example below:

  .right {
        float: right;
      }

      .left {
        float: left;
      }
// HTML

     Right
     Left

#html #css #web-development #developer

HTML Center Text – How to CSS Vertical Align a Div
3.75 GEEK