Open In App
Related Articles

HTML | DOM Style transformOrigin Property

Improve Article
Save Article
Like Article

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.

  • To set the transformOrigin property:"x-value y-value"
  • To return the transformOrigin property:
  • 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. 


<!DOCTYPE html>
        HTML | DOM Style transformOrigin Property
        //the following script will find element
        // whose id is circle2 and transform
        //it's position to origin
        function myFunction() {
              "circle2").style.transformOrigin =
              "0 0";
        #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%;
    <button onclick="myFunction()">
    <div id="circle1">
        <div id="circle2"></div>
        <div id="circle3"></div>


  • 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


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 07 Jun, 2022
Like Article
Save Article
Similar Reads
Complete Tutorials