Skip to content
Related Articles

Related Articles

HTML align Attribute

View Discussion
Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 06 Jun, 2022

The align Attribute in HTML is used to specify the alignment of text content of The Element. this attribute is is used in all elements. The Align attribute can also be set using CSS property “text-align: ” or in <img> “vertical-align: “.

Supported Tags: 

  • <applet>
  • <caption>
  • <col>
  • <colgroup>
  • <hr>
  • <iframe>
  • <img>
  • <legend>
  • <table>
  • <tbody>
  • <td>
  • <tfoot>
  • <th>
  • <thead>
  • <tr>


<element_name align="left | right | center | justify">

Attribute Values:

  • left: It sets the text left-align.
  • right: It sets the text right-align.
  • center: It sets the text center-align.
  • justify: It stretch the text of paragraph to set the width of all lines equal.

Example 1:


<!DOCTYPE html>
        HTML p align Attribute
    <h2>HTML p align Attribute</h2>
    <p align="left">
    Left align content
    <p align="center">
    center align content
    <p align="right">
    Right align content


Example 2: 


<!DOCTYPE html>
    <style type=text/css>
        p {
            background-color: gray;
            margin: 10px;
        div {
            color: white;
            background-color: 009900;
            margin: 2px;
            font-size: 25px;
        body {
            text-align: center;
    <h2><div>align Attribute</h2>
    <div align="center">
    div align="center"
    <div align="left">
    div align="left"
    <div align="right">
    div align="right"
    <div align="justify">
    div align="justify"


Supported Browsers: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!