Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App

HTML | DOM Style verticalAlign Property

Last Updated : 05 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

This property is used to set or return the vertical alignment of the content in an element. 

Syntax:

  • Return VerticalAlign :
object.style.verticalAlign
  • Set VerticalAlign :
object.style.verticalAlign = value

Properties:

ValueDescription
lengthIt is used to raise or lower an element by some given length.
%It is used to raise or lower an element in percentage of the “line-height” property.
baselineIt is the default property, which is used to align the baseline of the element with the baseline of the parent element.
subIt is used to align the element as a subscript.
superIt is used to align the element as a superscript.
topIt is used to align the top of the element with the top of the tallest element on the line.
text-topIt is used to align the top of the element with the top of the parent element’s font.
middleIt is used to place the element in the middle of the parent element.
bottomIt is used to align the bottom of the element, with the lowest element on the line.
text-bottomIt is used to align the bottom of the element with the bottom of the parent element’s font
initialIt is used to set VerticalAlign property to its default value.
inheritIt is used to inherit property values from its parent element.

Return Value: It is used to return a string, representing the vertical alignment of the content in an element. 

Example 1: Showing bottom property 

HTML
<!DOCTYPE html> <html> <head>     <head>         HTML | DOM Style verticalAlign Property     </head> </head> <body>     <h1>         <center>             DOM VerticalAlign Property              <button onclick="align()">Press</button>         </center>     </h1>     <h3>           Clicking on the 'Press' button will align         the text vertically at the bottom.       </h3>     <style>         table {             border: 4px solid black;             height: 200px;             width: 600px;         }     </style>     <table>         <tr>             <td id="myTd">                 <center>                     <h1>GeeksforGeeks</h1>                 </center>             </td>         </tr>     </table>     <br>     <script>         function align() {              // Set align bottom.             document.getElementById(                 "myTd").style.verticalAlign =                 "bottom";         }     </script> </body> </html> 

Output:

  • Before clicking on the button: 

  • After clicking on the button: 

Example 2: Showing top property 

HTML
<!DOCTYPE html> <html> <head>     <head>         HTML | DOM Style verticalAlign Property     </head> </head> <body>     <h1>         <center>             DOM VerticalAlign Property              <button onclick="align()">Press</button>         </center>     </h1>     <h3>         Clicking on the 'Press' button will         align the text vertically at the top.     </h3>     <style>         table {             border: 4px solid black;             height: 200px;             width: 600px;         }     </style>     <table>         <tr>             <td id="myTd">                 <h1>                     <center>GeeksforGeeks</center>                 </h1>             </td>         </tr>     </table>     <br>     <script>         function align() {              // Set align top.             document.getElementById(                 "myTd").style.verticalAlign =                 "top";         }     </script> </body> </html> 

Output:

  • Before clicking on the button: 

  • After clicking on the button: 

Example 3: Showing baseline property 

HTML
<!DOCTYPE html> <html> <head>     <head>         HTML | DOM Style verticalAlign Property     </head> </head> <body>     <h1>         <center>             DOM VerticalAlign Property              <button onclick="align()">Press</button>         </center>     </h1>     <h3>           Clicking on the 'Press' button will align the         text vertically with the baseline of the parent.       </h3>     <style>         table {             border: 4px solid black;             height: 200px;             width: 600px;         }     </style>     <table>         <tr>             <td id="myTd">                 <h1>                     <center>                         GeeksforGeeks                     </center>                 </h1>             </td>         </tr>     </table>     <br>     <script>         function align() {              // Set align baseline             document.getElementById(                 "myTd").style.verticalAlign =                 "baseline";         }     </script> </body> </html> 

Output: 

  • Before clicking on the button: 

 

  • After clicking on the button: 

 

Example 4: Showing initial property 

HTML
<!DOCTYPE html> <html> <head>     <head>         HTML | DOM Style verticalAlign Property     </head> </head> <body>     <h1>         <center>             DOM VerticalAlign Property              <button onclick="align()">Press</button>         </center>     </h1>     <h3>         Clicking on the 'Press' button will align         the text vertically to the initial position.     </h3>     <style>         table {             border: 4px solid black;             height: 200px;             width: 600px;         }     </style>     <table>         <tr>             <td id="myTd">                 <h1>                     <center>                         GeeksforGeeks                     </center>                 </h1>             </td>         </tr>     </table>     <br>     <script>         function align() {              // Set align initial             document.getElementById(                 "myTd").style.verticalAlign =                 "initial";         }     </script> </body> </html> 

Output:

  • Before clicking on the button: 

  • After clicking on the button: 

Example 5: Showing inherit property 

HTML
<!DOCTYPE html> <html> <head>     <head>         HTML | DOM Style verticalAlign Property     </head> </head> <body>     <h1>         <center>             DOM VerticalAlign Property              <button onclick="align()">Press</button>         </center>     </h1>     <h3>         Clicking on the 'Press' button will align the         text vertically to the inherited position.     </h3>     <style>         table {             border: 4px solid black;             height: 200px;             width: 600px;         }     </style>     <table>         <tr>             <td id="myTd">                 <h1>                     <center>                         GeeksforGeeks                     </center>                 </h1>             </td>         </tr>     </table>     <br>     <script>         function align() {              // Set align inherit             document.getElementById(                 "myTd").style.verticalAlign =                 "inherit";         }     </script> </body> </html> 

Output:

  • Before clicking on the button: 

  • After clicking on the button: 

Browser Support: The browsers supported by DOM VerticalAlign Property are listed below:

  • Google Chrome 1
  • Edge 12
  • Internet Explorer 4
  • Firefox 1
  • Opera 4
  • Safari 1

R

riarawal99
Improve
Article Tags :
  • Web Technologies
  • HTML
  • HTML-DOM

Similar Reads

    HTML | DOM Form enctype Property
    The Form enctype property in HTML DOM is used to set or return the value of the enctype attribute in a form. This attribute specifies the data that will be present in the form should be encoded when submitting to the server. This type of attribute can be used only if method = "POST". Syntax: It is u
    3 min read
    HTML DOM Form reset() Method
    The reset() method in the HTML DOM is used to reset a form fields to their default values. When a form is reset, all user input is cleared, and the fields revert to their initial states.SyntaxformObject.reset()Example: In this example, clicking the reset button clears the form inputs. html<!DOCTY
    1 min read
    HTML | DOM Form submit() Method
    The form submit() Method in HTML DOM is used to send the form data to the web-server. It works as same as submit button. It does not contain any parameters. Syntax: formObject.submit()Example: index.html<!DOCTYPE html> <html> <head> <title> HTML DOM Form submit() Method </
    1 min read
    HTML | DOM Location Search Property
    The Location Search property in HTML DOM is used to set or return the query part of URL including question mark. The query part is the part of URL after the question mark. Syntax: It returns the location search property.location.searchIt is used to set the location search property.location.search =
    1 min read
    HTML DOM Form action Property
    The HTML DOM Form action property allows accessing and modifying the action attribute of a form element through JavaScript. It determines the URL where form data is submitted when the form is submitted. Syntax: It is used to return the action property. formObject.actionIt is used to set the action p
    3 min read
    HTML | DOM Form autocomplete Property
    The Form autocomplete property in HTML DOM is used to set or return of the autocomplete attribute. The autocomplete attribute is used to specify whether the autocomplete attribute has "on" or "off" value. When the autocomplete attribute is set to on so the browser will automatically complete the val
    2 min read
    HTML | DOM Textarea rows Property
    The DOM Textarea rows Property is used to set or return the value of a rows attribute of a textarea field. The rows attribute specifies the number of visible text lines for the control i.e the number of rows to display. Syntax: It is used to Return the rows property:textareaObject.rowsIt is used to
    2 min read
    HTML DOM Video Object
    The Video object in HTML DOM represents an <video> element. The video element can be accessed by using getElementById() method. Syntax: To access a video object: document.getElementById("videoId");where id is assigned to the <video> tag.To create a video object: document.createElement("V
    4 min read
    HTML | DOM Input Month Object
    The Input Month Object in HTML DOM is used to represent an HTML input element with type= "month" attribute. The input element with type= "month" attribute can be accessed by using getElementById() method. Syntax: It is used to access <input> element with type="month" attribute.document.getElem
    3 min read
    HTML | DOM Style flexGrow Property
    The HTML DOM style flexGrow property is used as a measure to determine how much an item will grow relative to the rest of the flexible items inside the same container. Syntax: Return flexGrow property:object.style.flexGrowSet flexGrow property:object.style.flexGrow = "number|initial|inherit" Propert
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences