How to align text in Html

In HTML, we can align a text using the following two ways:

  1. Using HTML tag (
    tag)
  2. Using style attribute

Using HTML tag

If we want to move a text at center position using the Html tag which is to be displayed on a web page, we have to follow the steps which are given below.

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to align a text at center:

Step 2: Now, move the cursor at the starting of that text whose alignment we want to specify as the center. And then, type the Html tag at that point.

Step 3: Then, we have to close the center tag at the end of that text which we want to place at the center position.

Step 4: And, at last, save the Html file and then run that file.

Test it Now

The output of above code is shown in the following screenshot:

How to align text in Html

Using Style Attribute

If we want to align a text using inline style attribute which is to be displayed on a web page, we have to follow the steps which are given below.

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the style attribute for aligning a text or paragraph.

Step 2: Now, move the cursor at the starting of that text whose alignment we want to specify. And then, type the CSS style attribute within the

(paragraph) tag

.

Step 4: And, at last, save the Html code which changes the position of a text or a paragraph.

Test it Now

The output of the above Html code is shown in the following screenshot:

How to align text in Html




Contact US

Email:[email protected]

How to align text in Html
10/30