HTML | <div> align Attribute

The HTML div align Attribute is used to specify the alignment of the <div> element or the content present inside the div Element.

Syntax:

<div align="left | right | center | justify";>

Attribute Values:

  • left: It sets the content to the left-align.
  • right: It sets the content to the right-align.
  • center: I sets the div element to the center.
  • justify: It sets the content to the justify position.

Example:

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: The browsers supported by HTML div align Attribute are listed below:

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


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.