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 paddingTop Property

Last Updated : 14 Jul, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The Style paddingTop property is used for setting or returning the top padding of an element. The padding property inserts the user desired space within the border of an element. 

Syntax :

  • To get the property:
object.style.paddingTop
  • To set the property:
object.style.paddingTop = "%|length|initial|inherit"

Return Values: It returns a string value, which represents the top padding of an element

Property Values :

  • % : It is used to define the top padding in % of the width of the parent element.
  • length : It is used to define the top padding in length units.
  • initial : It is used to set this property to its default value.
  • inherit : It is used to inherit this property from its parent element.

Below program illustrates the Style paddingTop property method : 

Example: Setting the top padding of a <div> element. 

html
<!DOCTYPE html> <html>  <head>     <title>Style paddingTop in HTML</title>     <style>         #MyElement {             border: 1px solid black;             background-color: green;             width: 300px;             height: 300px;         }                  h1 {             color: green;         }                  h2 {             font-family: Impact;         }                  body {             text-align: center;         }     </style> </head>  <body>      <h1>GeeksforGeeks</h1>     <h2>Style paddingTop</h2>      <p>For setting the top padding,       double click the "Apply Top Padding" button: </p>     <br>      <button ondblclick="padding()">Apply Top Padding</button>      <div id="MyElement">         Geeksforgeeks is a portal for geeks.     </div>      <script>         function padding() {             document.getElementById("MyElement")             .style.paddingTop = "100px";         }     </script>  </body>  </html> 

Output:

  • Before Clicking the button: 

  • After clicking the button: 

Supported Browsers: The browser supported by HTML | DOM Style paddingTop Property are listed below:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer 4 and above
  • Firefox 1 and above
  • Opera 3.5 and above
  • Apple Safari 1 and above

S

Shubrodeep Banerjee
Improve
Article Tags :
  • Web Technologies
  • HTML
  • HTML-DOM

Similar Reads

    HTML | DOM Style fontVariant Property
    The style fontVariant Property in DOM HTML is used to set the font in capital letters. This property mainly converts lowercase to uppercase letters but the letters have a small font size compared to remaining text. Syntax: It returns the fontVariant property.object.style.fontVariantIt used to set th
    2 min read
    HTML | DOM Location replace() Method
    The DOM Location replace() Method in HTML is used to replace the current document with the specified one. This method is different from the assign() method as this removes the current document from the document history, therefore it is not possible to go back to the previous document using the 'back
    1 min read
    HTML DOM Style columnRule Property
    The Style columnRule property in HTML DOM sets or returns the width, style, and color of the rule between the columns. To get the columnRule Propertyobject.style.columnRule = valueTO set the columnRule propertyobject.style.columnRule = "column-rule-width column-rule-style column-rule-color | initial
    4 min read
    HTML | DOM Style textIndent Property
    The DOM Style textIndent Property is used for indentation of the first line in each block of text. It also takes negative values. If the value is negative then the first line will be indented to the left. Syntax: It is used to set the textIndent property:object.style.textIndent = "length|%|initial|i
    2 min read
    HTML DOM Style paddingLeft Property
    The Style paddingLeft property in HTML DOM is used to set or return the left padding of the element. Syntax: It returns the paddingLeft property. object.style.paddingLeftIt sets the paddingLeft Property. object.style.paddingLeft = "% | length | initial | inherit"Return value: It returns the string v
    2 min read
    HTML DOM | Style paddingRight Property
    The Style paddingRight property is used for setting or returning the right padding of an element. The padding property inserts the user desired space within the border of an element. Syntax : To get the property:object.style.paddingRightTo set the property:object.style.paddingRight = "%|length|initi
    2 min read
    HTML | DOM Style pageBreakBefore Property
    The pageBreakBefore property in HTML DOM is used to set or return the page-break-before characteristics before the specified element in HTML document. This property works in print and print preview mode. The pageBreakBefore property has no effect on absolutely positioned elements in the HTML DOM. Th
    2 min read
    HTML | DOM Summary Object
    The DOM Summary Object is used to represent the HTML <summary> element . The Summary element is accessed by getElementById(). Syntax: document.getElementById("ID"); Where “id” is the ID assigned to the “summary” tag. Example-1: html <!DOCTYPE html> <html> <head> <title>
    2 min read
    HTML | DOM Style userSelect Property
    The DOM Style UserSelect Property is used to set or return whether the text can be selected by the user or not. Syntax: It is used to return the property: object.style.userSelectIt is used to set the property: object.style.userSelect = "auto|none|text|all" Properties : auto: It has the default value
    2 min read
    HTML | DOM Title Object
    The Title Object in HTML DOM is used to represent the HTML <title> element. The <title> element can be accessed by using getElementByTagName() method. Syntax: document.getElementByTagName(); Properties: The title object contains single property text which is used to set or return a text
    2 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