Open In App

HTML | DOM TableRow align Property

Last Updated : 25 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML DOM TableRow align Property is used to set or return the horizontal alignment of the content within the table row. It is not supported by HTML 5.

Syntax:

  • It returns the align property.
    TableRowobject.align
  • It sets the align property.
    TableRowObject.align = "left | right | center | justify | char"

Property Values:

  • left: It sets the left-align to TableRow.
  • center: It sets the center-align to TableRow. It is the default value.
  • right: It sets the right-align to TableRow.
  • justify: It stretches the text of paragraph to set the width of all lines equal.
  • char: It sets the text-align to a specific character.

Return Values: It returns a string value which represents the alignment of the TableRow element.

Example 1: This example sets the TableRow align Property.




<!DOCTYPE html> 
<html
      
<head
    <style
        table, th, td { 
            border: 1px solid green; 
        
    </style
</head
  
<body
  
    <h1
        GeeksForGeeks 
    </h1
          
    <h2>HTML DOM tableRow align Property</h2
  
    <table
        <tr id = "GFG" align = "left"
            <td>Geeks</td
            <td>Geeks</td
            <td>For</td
            <td>Geeks</td
        </tr
    </table
  
    <button onclick = "myGeeks()"
        Click Here! 
    </button
    <p id ="sudo"></p>
      
    <script
        function myGeeks() { 
            var row = document.getElementById("GFG").align; 
            document.getElementById("sudo").innerHTML = row; 
        
    </script
</body
  
</html>                     


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Example 2:




<!DOCTYPE html> 
<html
      
<head
    <style
        table, th, td { 
            border: 1px solid green; 
        
    </style
</head
  
<body
    <h1
        GeeksForGeeks 
    </h1
          
    <h2>HTML DOM tableRow align Property</h2
  
    <table
        <tr id = "GFG" align = "left"
            <td>Geeks</td
            <td>Geeks</td
            <td>For</td
            <td>Geeks</td
        </tr
    </table
  
    <button onclick = "myGeeks()"
        Click Here! 
    </button
    <p id ="sudo"></p>
      
  
    <script
        function myGeeks() { 
            var row = document.getElementById("GFG").align = "right"; 
            document.getElementById("sudo").innerHTML = 
                        "The value was changed to  " + row;
        
    </script
</body
  
</html>


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Supported Browsers: The browsers supported by DOM TableRow align Property are listed below:

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads