Position Elements on a Web Page Using CSS Positioning

CSS allows different methods to position your elements. Understanding how CSS affects the on-page alignment can improve your designing skills and the overall user experience of the page. In this tutorial, you will focus on the CSS position property. You will learn the various values of the CSS position property, and how they work. 

What is CSS Position Property?

The CSS position property determines how an element should be positioned in an HTML document. The top, right, bottom, and left properties set the final position of the elements.

There are four different position values:

  1. CSS Static Positioning
  2. CSS Fixed Positioning
  3. CSS Relative Positioning
  4. CSS Absolute Positioning 

Let’s discuss each of them separately.

Want a Top Software Development Job? Start Here!

Full Stack Developer - MERN StackExplore Program
Want a Top Software Development Job? Start Here!

CSS Static Positioning

The position of the HTML elements is static by default. It sets the position according to the normal flow of the page. The top, bottom, left, and right properties do not affect it.

css-static-1

css-static-2.

CSS Fixed Positioning

The fixed positioning property positions the element relative to the screen's viewport and stays fixed on the screen when scrolling.

css-fixed-1

css-fixed-2.

CSS Relative Positioning

The relative positioning positions the element relative to where its normal position would have been.

css-relative-1

css-relative-2.

CSS Absolute Positioning

The absolute value positions the element absolutely relative to its container. With absolute positioning, you can place an element anywhere on a page.

css-absolute-1

css-absolute-2.

Stand Out From Your Peers this Appraisal Season

Start Learning With Our FREE CoursesEnroll Now
Stand Out From Your Peers this Appraisal Season

Z-Index

The Z-Index property is used to specify the stacking order of the elements that overlap. The stack level refers to the element’s position on the Z-axis.

css-z-index.

z-index-2

Get skilled in HTML5 and CSS3 with the Full Stack Java Developer Master's Program. Click to check out the program details! 

Conclusion

We hope this CSS Positioning tutorial has helped you to understand the CSS position property and its workings. Mastering CSS takes constant practice. So, keep practicing to get better at it.

If you want to gain more knowledge about Full Stack Development, you can check Simplilearn’s Postgraduate Program in Full Stack Web Development course, in collaboration with Caltech CTME. In this course, you'll master the skills required to be a full-stack technologist.

If you have any questions or feedback regarding the CSS Positioning tutorial, let us know in the comments section. Our experts will get back to you as soon as possible.

Happy learning!

About the Author

Aryan GuptaAryan Gupta

Aryan is a tech enthusiast who likes to stay updated about trending technologies of today. He is passionate about all things technology, a keen researcher, and writes to inspire. Aside from technology, he is an active football player and a keen enthusiast of the game.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.