
- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - left Property
CSS left property is used to specify the horizontal position of a positioned element relative to its containing element. It determines the left edge position of an element. Based on the value of the position property, the effect of left property, is determined.
Syntax
left: auto | length | percentage | initial | inherit;
Property Values
Value | Description |
---|---|
auto | The browser calculates the left position. Default. |
length | It specifies the left edge position in length units (px, em, rem etc.). Negative values are allowed. |
percentage | It specifies the left edge position in percentage relative to the containing element. Negative values are allowed. |
initial | It sets the property to its default value. |
inherit | It inherits the property from the parent element. |
Examples of CSS Left Property
The following examples explain the left property with different values.
Left Property with Absolute Position
With the position: absolute, the left property determines the horizontal distance of the element's left edge to the nearest positioned ancestor. If no positioned ancestor exists, it is positioned from the initial containing block. This is shown in the following example. Different units for the distances have been used.
Example
<!DOCTYPE html> <html> <head> <style> .box { background-color: lightgreen; padding: 10px; color: green; } .absolute-box { font-weight: bold; position: absolute; width: 130px; height: 50px; padding: 2px; border: 3px solid green; background-color: #bbedbb; color: #e50c0c; } .left { left: 0; } .left-px { left: 60px; } .left-per { left: 30%; } .left-em { left: 4em; } .left-auto { left: auto; } </style> </head> <body> <h2> CSS left property </h2> <h4> position: absolute </h4> <div class="box"> <div class="absolute-box left"> position:absolute; left: 0; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="absolute-box left-px"> position:absolute; left: 60px; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="absolute-box left-per"> position:absolute; left: 30%; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="absolute-box left-em"> position:absolute; left: 4em; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="absolute-box left-auto"> position:absolute; left: auto; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. </div> </body> </html>
Left Property with Fixed Position
With the position: fixed, the left property sets the distance of the element from the viewports left edge. The element maintains its position even during page scroll. This is shown in the following example. Different units for the distances have been used.
Example
<!DOCTYPE html> <html> <head> <style> .box { background-color: lightgreen; padding: 10px; color: green; } .fixed-box { font-weight: bold; position: fixed; width: 130px; height: 50px; padding: 2px; border: 3px solid green; background-color: #bbedbb; color: #e50c0c; } .left-px { left: 60px; } .left-per { left: 30%; } .left-auto { left: auto; } </style> </head> <body> <h2> CSS left property </h2> <h4> position: fixed </h4> <div class="box"> <div class="fixed-box left-px"> position: fixed; left: 60px; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="fixed-box left-per"> position: fixed; left: 30%; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="fixed-box left-auto"> position: fixed; left: auto; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. </div> </body> </html>
Left Property with Relative Position
With the position: relative, the left property positions the element relative to the normal position. If positive values are given, the element moves towards the right and if negative values are given, the element moves towards the left without disturbing other elements. This is shown in the following example. Different units for the distances have been used.
Example
<!DOCTYPE html> <html> <head> <style> .box { background-color: lightgreen; padding: 10px; color: green; } .relative-box { font-weight: bold; position: relative; width: 130px; height: 50px; padding: 2px; border: 3px solid green; background-color: #bbedbb; color: #e50c0c; } .left { left: 0; } .left-px { left: 60px; } .left-per { left: 30%; } .left-em { left: 4em; } .left-auto { left: auto; } </style> </head> <body> <h2> CSS left property </h2> <h4> position: relative </h4> <div class="box"> <div class="relative-box left"> position: relative; left: 0; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="relative-box left-px"> position: relative; left: 60px; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="relative-box left-per"> position: relative; left: 30%; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="relative-box left-em"> position: relative; left: 4em; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="relative-box left-auto"> position: relative; left: auto; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. </div> </body> </html>
Left Property with Static Position
With the position: static, the left property has no effect, the element is positioned according to the normal document flow. This is shown in the following example.
Example
<!DOCTYPE html> <html> <head> <style> .box { background-color: lightgreen; padding: 10px; color: green; } .static-box { font-weight: bold; position: static; width: 130px; height: 50px; padding: 2px; border: 3px solid green; background-color: #bbedbb; color: #e50c0c; } .left { left: 0; } .left-px { left: 60px; } .left-per { left: 30%; } .left-em { left: 4em; } .left-auto { left: auto; } </style> </head> <body> <h2> CSS left property </h2> <h4> position: static </h4> <div class="box"> <div class="static-box left"> position: static; left: 0; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="static-box left-px"> position: static; left: 60px; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="static-box left-per"> position: static; left: 30%; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="static-box left-em"> position: static; left: 4em; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="static-box left-auto"> position: static; left: auto; </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. </div> </body> </html>
Left Property with Sticky Position
With the position: sticky, the left property controls the elements position within its containing block until it reaches a defined threshold. After crossing this threshold during scrolling, the element behaves as if it is fixed, sticking to the position defined by the left property. This is shown in the following example. Different units for the distances have been used.
Example
<!DOCTYPE html> <html> <head> <style> .box { background-color: lightgreen; color: green; padding: 10px; } .sticky-container { position: relative; } .sticky-box { position: sticky; width: 130px; height: 60px; padding: 2px; border: 3px solid green; background-color: #bbedbb; color: #e50c0c; font-weight: bold; top: 10px; } .left { left: 40px; } </style> </head> <body> <h2> CSS left property </h2> <h4> position: sticky </h4> <div class="box"> <div class="sticky-container"> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. <div class="sticky-box left"> position: sticky; left: 40px. </div> TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. TutorialsPoint is a versatile online educational platform that provides a vast array of free tutorials and courses across numerous subjects,such as programming, web development, data science, and more. It caters to learners of all levels, offering detailed explanations, practical examples, and interactive exercises to enhance understanding and skills.Ideal for self-paced learning and skill development. </div> </div> </body> </html>
Position value | Bottom property |
---|---|
absolute or fixed | It specifies the distance between element's left edge's outer margin and the inner border of the container's left edge. |
relative | It specifies the distance the element's left edge is moved to the right from its normal position. |
sticky | The property behaves like its position is relative when the element is inside the viewport like fixed when it is outside. |
static | No effect of the left property on the element. |
Supported Browsers
Property | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
left | 1.0 | 5.5 | 1.0 | 1.0 | 5.0 |