left

In this chapter you will learn:

  1. Definition, default value, CSS version and JavaScript syntax for left
  2. Syntax to create left property and meaning for each of its property value
  3. An example showing how to use left CSS property

Description

left defines the offset for the left edge of a positioned element.

ItemValue
Initial value auto
Inherited No.
Version CSS2
JavaScript syntax object.style.left="5px"
Applies to Positioned elements (position value is not static).

Syntax and Property Values

left: length | percentage | auto | inherit

The property values are listed in the following table.

ValueDescription
auto Default value. The browser does the calculation.
length Set left in px, cm, etc. Negative values allowed
% Sets the left edge position in % of containing element. Negative values allowed
inherit Inherit the left property from the parent element

Example

<!DOCTYPE HTML><!--from  j  ava2s .  c  o  m-->
<html>
    <head>
        <style>
div {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 1px solid rgb(200, 200, 200);
    z-index: auto;
}
div#one {
    background: pink;
    top: 10px;
    left: 10px;
}
div#two {
    background: lightblue;
    top: 20px;
    left: 20px;
}
div#three {
    background: yellowgreen;
    top: 30px;
    left: 30px;
}
div#four {
    background: orange;
    top: 40px;
    left: 40px;
}        
        </style>
    </head>
    <body>
        <div id='one'></div>
        <div id='two'></div>
        <div id='three'></div>
        <div id='four'></div>
    </body>
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. Definition, default value, CSS version and JavaScript syntax for letter-spacing
  2. Syntax to create letter-spacing property and meaning for each of its property value
  3. An example showing how to use letter-spacing CSS property
Home » HTML CSS Tutorial » CSS Reference
background
background-clip
background-color
background-origin
background-position
background-repeat
background-size
border
border-bottom
border-bottom-color
border-bottom-left-radius
border-bottom-right-radius
border-bottom-style
border-bottom-width
border-collapse
border-color
border-left
border-left-color
border-left-style
border-left-width
border-radius
border-right
border-right-color
border-right-style
border-right-width
border-spacing
border-style
border-top
border-top-color
border-top-left-radius
border-top-right-radius
border-top-style
border-top-width
border-width
bottom
caption-side
clear
color
content
counter-increment
counter-reset
cursor
direction
display
empty-cells
float
font
font-family
font-size
font-style
font-variant
font-weight
height
left
letter-spacing
line-height
list-style
list-style-image
list-style-position
list-style-type
margin
margin-bottom
margin-left
margin-right
margin-top
max-height
max-width
min-height
min-width
opacity
outline
outline-color
outline-offset
outline-style
outline-width
overflow
overflow-x
overflow-y
padding
padding-bottom
padding-left
padding-right
padding-top
position
quotes
right
table-layout
text-align
text-decoration
text-indent
text-overflow
text-shadow
text-transform
top
vertical-align
visibility
white-space
width
word-spacing
z-index