HTML align Attribute

The align Attribute in HTML is used to is used to specify the alignment of text content of The Element. this attribute is is used in all elements.

Syntax:

<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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title
        HTML p align Attribute 
    </title
</head
  
<body
    <h1>GeeksforGeeks</h1
  
    <h2>HTML p align Attribute</h2
  
    <p align="left"
    Left align content 
</p
    <p align="center"
    center align content 
</p
    <p align="right"
    Right align content 
</p
</body
  
</html

chevron_right


Output:



Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title>gfg</title
    <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; 
        
    </style
  
</head
  
<body
    <h1>GeeksForGeeks</h1
    <h2><div>align Attribute</h2
    <div align="center"
    div align="center" 
</div
    <div align="left"
    div align="left" 
</div
    <div align="right"
    div align="right" 
</div
    <div align="justify"
    div align="justify" 
</div
  
</body
  
</html

chevron_right


Output:

Supported Browsers:

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

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.