CSS position left property

CSS Position left Property

Description

The left property defines the offset of the left edge of an absolutely positioned element relative to the left edge of its positioning context, or the horizontal distance that a relatively positioned element will be displaced.

Possible Values

  • length − A fixed distance relative to the left edge of the positioning context.
  • percent − A percentage of the positioning context’s width, assuming the context’s width has been explicitly set.


  • auto − Default value. Let the browser calculate the left position.

Applies to

All HTML positioned elements.

DOM Syntax

object.style.left = "2px"; 

Example

Here is an example showing the effect of this property –

<html> 
<head> 
</head> 

<body> 
<p style = "position:absolute; left:100px;"> 
This line will be positioned 100px away from the left edge of this window.
</p> 
</body> 
</html> 

Here’s the output:

CSS position left property

Leave a Reply

Your email address will not be published. Required fields are marked *