
Suppose you have some text on your web page, for example: Welcome to freeCodeCamp You use this property to specify the horizontal alignment of text in an element. The major CSS property that works well with text alignment is the text-align property. With CSS, you have many options that you can use to align your text. You should use HTML only to add markup to your web page.

Remember that it's essential to always handle all stylings with CSS. This will output all our text in the center of the page or whatever container it is applied to:īut now that we have HTML5, we don't use this method anymore.

Necessitatibus quod velit vitae unde sed? Expedita consequuntur ea quis reiciendis nobis distinctio quod deserunt doloremque in. Lorem ipsum dolor sit amet consectetur adipisicing elit.

Although this may still work with some major browsers, it might get dropped at any point. For example, you could use the center tag to align your text to the center, but in HTML4, this tag got depreciated. How to Align Text to Center Before HTML5īefore the introduction of HTML5, developers performed specific styling with HTML tags. You can also do the same on your web pages using code. This is similar to what you do when editing texts in Microsoft Word or Google Docs, using the left align, right align, center, and justify buttons.

You might even want the text to fill up your page or container. You will want some to be in the center, some to the left, and others to the right. When you add text to your web page, it dictates the direction and feel of your web page based on your language.įor example, by default, English moves from left to right (LTR), while Arabic moves from right to left (RTL).īut most times, you won't want all your text to remain in only one position of your screen or container. Text is essential on web pages, as it tells your users what your web page is all about.
