How to Align Text in HTML ?

  • By using markup language, HTML is used to design webpages.
  • It defines the link between the webpages.
  • It defines the structure of webpages where markup language is used to define the text document within tag.
  • In required format HTML is used by the browser to manipulate text, images, and other content to display.
  • By using the text-align property, we can change the alignment of the text.
  • We can align the text in the Left, Right and Center.
  • The text alignment can be done with HTML Attribute tag and Cascade Style Sheet.
  • In Webpage, HTML allows the use of these CSS to perform changes in the style of the content.

Align text to left

Sample Code

<!DOCTYPE html>
<html>
<body>

<h1 style="text-align:left;">Welcome to Wikitechy</h1>
<p style="text-align:left;">Hi this is Venkat .</p>

</body>
</html>

Output

Align text to Right

 Sample Code

<!DOCTYPE html>
<html>
<body>

<h1 style="text-align:right;">Welcome to Wikitechy</h1>
<p style="text-align:right;">Hi this is Venkat .</p>

</body>
</html>

Output

Align text to Center

Sample Code

<!DOCTYPE html>
<html>
<body>

<h1 style="text-align:center;">Welcome to Wikitechy</h1>
<p style="text-align: center;">Hi this is Venkat .</p>

</body>
</html>

Output

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

What is a marquee tag ?

In HTML it is used to create scrolling text or image in a webpage. It scrolls either from vertically top to bottom or bottom to top or horizontally left to…
View Answer

How do you add buttons in HTML ?

In HTML <button> tag is used to clickable button within form on your webpage. We can put content like image or text within the <button>to</button> tag. For <button> tag we should…
View Answer