Absolute Positioning with CSS

When elements are positioned absolutely, they are removed from the normal flow. As a result, they do not affect the positioning of subsequent sibling elements. Learn how to use absolute positioning in the following steps.

  1. Set the position property to absolute.
    h1 {
  3. Set one or more "offset" properties.

    The "offset" properties are top, right, bottom, and left. Their values can be specified in number of units (e.g., 10px) or percentage of the containing block (e.g., 20%). These properties offset the element from its nearest non-statically positioned containing block element (i.e., with position set to absolute, relative, or fixed). If it has no ancestor that is non-statically positioned, then it is offset from the browser window.

    h1 {
    	top: 70px;
    	left: 50px;
  5. The following example demonstrates absolute positioning:
    <meta charset="UTF-8">
    <style type="text/css">
    h1 {
    	border:2px solid #006;
    #explanation {
    #wrapper {
    	border:1px solid #006;
    <title>CSS Absolute Positioning</title>
    <div id="wrapper">
    	<h1>CSS Absolute Positioning</h1>
    	<h2>From the Left and the Top</h2>
    	<div id="explanation">
    		<p>Notice how this text is in the upper corner.</p>
    		<p>That's because the preceding h1 element has been absolutely positioned.</p>
    		<p>Positioning an element absolutely takes the element out of the regular flow of the document.</p>
    This code renders the following:
    Absolute Positioning
Author: Chris Minnick

Chris Minnick, the co-founder of WatzThis?, has overseen the development of hundreds of web and mobile projects for customers from small businesses to some of the world’s largest companies. A prolific writer, Chris has authored and co-authored books and articles on a wide range of Internet-related topics including HTML, CSS, mobile apps, e-commerce, e-business, Web design, XML, and application servers. His published books include Adventures in Coding, JavaScript For Kids For Dummies, Writing Computer Code, Coding with JavaScript For Dummies, Beginning HTML5 and CSS3 For Dummies, Webkit For Dummies, CIW E-Commerce Designer Certification Bible, and XHTML.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.