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

Last Updated : 07 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Every HTML element has some position on the screen. This position is described using co-ordinate geometry using x-axis and y-axis. The HTML DOM Style transformOrigin Property used to change the position of an HTML div. 
It helps in both 2D and 3D transformation.
Syntax: 
 

  • To set the transformOrigin property: 
     
object.style.transformOrigin="x-value y-value"  
  • To return the transformOrigin property: 
     
object.style.transformOrigin
  • Return Values: It returns a string value that represents the transform-origin property of an element
  • x-axis: Placed value of x-axis.
  • y-axis: Placed value of y-axis.
  • z-axis: placed value of z-axis in 3D.
  • initial: Set default value of element.
  • inherit: Inherit from its parent element


Example: Transform the origin of circle 2. 
 

html
<!DOCTYPE html> <html>  <head>     <title>         HTML | DOM Style transformOrigin Property     </title>     <script>         //the following script will find element          // whose id is circle2 and transform         //it's position to origin         function myFunction() {             document.getElementById(               "circle2").style.transformOrigin =                "0 0";         }     </script>        <style>         #circle1 {             height: 150px;             width: 150px;             margin: auto;             border: 1px solid black;             border-radius: 50%;         }                  #circle2 {             width: 150px;             height: 150px;             border: 1px solid black;             background-color: #0f9d58;             transform: rotate(45deg);             border-radius: 50%;         }                  #circle3 {             position: absolute;             width: 150px;             height: 150px;             border: #0f9d58;             background-color: #0f9d58;             opacity: 0.5;             border-radius: 50%;         }     </style> </head>  <body>     <button onclick="myFunction()">       Submit   </button>        <div id="circle1">         <div id="circle2"></div>         <div id="circle3"></div>     </div> </body>  </html> 

Output 
 

  • Before clicking on button: 
     

  • After clicking on button 
     


Note: For safari used "WebkitTransformOrigin" instead of "transformOrigin".
Supported Browsers: The browsers supported by HTML | DOM Style transformOrigin Property are listed below: 
 

  • Google Chrome
  • Edge
  • Firefox
  • Opera


 


S

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

Similar Reads

    HTML | DOM KeyboardEvent shiftKey Property
    The KeyboardEvent shiftKey property in HTML DOM is a read-only property and used to return a Boolean value which indicates the SHIFT key is pressed or not. The KeyboardEvent shiftKey property returns true if the SHIFT key is pressed, otherwise returns false. Syntax: event.shiftKey Below program illu
    1 min read
    HTML | DOM Form length Property
    The DOM Form length Property is used to return the number of input field contained in the form. Syntax: formObject.length Return Value: It returns a numeric value which represent the number of input field or elements in the Form. Example-1: Return the number of input field. html <!DOCTYPE html
    2 min read
    HTML | DOM Form acceptCharset Property
    The DOM Form acceptCharset Property is used to set or return the value of the accept-charset attribute in the form Element. The accept-charset attribute is used to define the character encoding and is used for form submission. The default value of the accept-charset attribute is “UNKNOWN” string whi
    2 min read
    HTML | DOM KeyboardEvent metaKey Property
    The KeyboardEvent metaKey property in HTML DOM is a read-only property and is used to return a Boolean value which is used to check whether the META key is pressed or not. The KeyboardEvent metaKey property returns true if the META key is pressed, otherwise returns false. Syntax: event.metaKey Below
    1 min read
    HTML DOM Select Object
    The Select object in HTML DOM is used to represent an HTML <select> element. It provides properties and methods to manipulate the <select> element and its associated <option> elements.Syntax:To create <select> element. document.createElement("SELECT")To access <select>
    3 min read
    HTML | DOM TouchEvent touches Property
    The TouchEvent touches property in HTML DOM is used to return the array of touch object. It returns one for each finger that is currently touching to the surface. The touches property is a read only property and it returns an array of touch objects. Syntax: event.touches Return Value: It return the
    1 min read
    HTML | DOM form method Property
    The DOM Form method Property is used to set or returnthe value of the method attribute in the form. The method attribute is used to specify the HTTP method used to send data while submitting the form. There are two kinds of HTTP Methods, which are GET and POST. Syntax: It is used to return the metho
    3 min read
    HTML | DOM Form name Property
    The DOM Form name Property is used to set or return the value of the name attribute in a form. The name attribute is required for each input field. If the name attribute is not specified in an input field then the data of that field would not be sent at all. Syntax: It is used to return the name pro
    2 min read
    HTML | DOM Style alignSelf Property
    The DOM Style alignSelf property is used to set or return the alignment for a selected item inside a flexible container. Syntax: To get the alignSelf Propertyobject.style.alignSelfTo set the alignSelf Propertyobject.style.alignSelf = "auto | stretch | center | flex-start | flex-end | baseline | init
    6 min read
    HTML DOM Input Date Object
    HTML Input Date object represents an <input> element with type="date", enabling users to input dates conveniently via a built-in calendar interface on web forms. Syntax:  For creating a <input> element with the type ="date":var gfg = document.createElement("input") gfg.setAttribute("type
    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