SlideShare a Scribd company logo
2
Most read
5
Most read
11
Most read
CSS Positioning Elements
Dr.T.Abirami
Associate Professor
Department of IT
Kongu Engineering College
Perundurai
CSS Positioning Elements
• The positioning of an element can be done using the top, right,
bottom, and left properties.
• These specify the distance of an HTML element from the edge of the
viewport.
• To set the position by using the following properties, we have to
declare the positioning method.
• Fixed
• Static
• Relative
• Absolute
• Sticky
CSS helps to position your HTML
element.
The position property specifies the type of positioning method
used for an element (static, relative, absolute, fixed, or sticky).
• It always stays in the same place even if the page is scrolled.
• The top, right, bottom, and left properties are used to
position the element.
• The element is positioned relative to the browser window
Fixed Positioning
Fixed Positioning
<html>
<head>
</head>
<body>
<div style = "position:fixed; left:80px; top:40px; background-color:yellow;">
This div has fixed positioning.
</div>
</body>
</html>
Absolute Positioning
• An element with position: absolute is positioned at the specified
coordinates relative to your screen top-left corner.
• You can use two values top and left along with the position property
to move an HTML element anywhere in the HTML document.
• The element is positioned relative to its first positioned (not static)
ancestor element
<html>
<head>
</head>
<body>
<div style = "position:absolute; left:80px; top:20px; background-
color:yellow;">
This div has absolute positioning.
</div>
</body>
</html>
Relative Positioning
• The element is positioned relative to its normal position, so "left:20px"
adds 20 pixels to the element's LEFT position
• An element with position: relative; is positioned relative to its normal
position.
• Setting the top, right, bottom, and left properties of a relatively-
positioned element will cause it to be adjusted away from its normal
position.
• Other content will not be adjusted to fit into any gap left by the
element.
<html>
<head>
<style>
div.relative {
position: relative;
left: 30px;
border: 3px solid #73AD21;
}
</style>
</head>
<body>
<h2>position: relative;</h2>
<p>An element with position: relative</p>
<div class="relative">
This div element has position: relative;
</div>
</body>
</html>
position: static;
• HTML elements are positioned static by default.
• Static positioned elements are not affected by the top, bottom, left,
and right properties.
• An element with position: static; is not positioned in any special way;
it is always positioned according to the normal flow of the page:
• This <div> element has position: static;
<html>
<head>
<style>
div.static { position: static; border: 3px solid #73AD21; }
</style>
</head>
<body>
<h2>position: static;</h2>
<p>An element with position</p>
<div class="static">
This div element has position: static;
</div>
</body>
</html>
position: sticky;
• It is positioned based on the
user's scroll position.
<html>
<head>
<style>
div.sticky {
position: -webkit-sticky;
position: sticky;
top: 0;
padding: 5px;
background-color: #cae8ca;
border: 2px solid #4CAF50;
}
</style>
</head>
<body>
<p>Try to <b>scroll</b> inside this frame to understand how sticky
positioning works.</p>
<div class="sticky">I am sticky!</div>
<div style="padding-bottom:2000px">
<p>Scroll back up to remove the stickyness.</p>
</div>
</body>
</html>

More Related Content

PPTX
Css position
Webtech Learning
 
PPTX
Css Display Property
Webtech Learning
 
PPTX
Css pseudo-classes
Webtech Learning
 
PPT
Css Positioning Elements
sanjay2211
 
PPTX
HTML Forms
Nisa Soomro
 
PPTX
html-table
Dhirendra Chauhan
 
PPTX
CSS Positioning and Features of CSS3
Jaimin Brahmbhatt
 
Css position
Webtech Learning
 
Css Display Property
Webtech Learning
 
Css pseudo-classes
Webtech Learning
 
Css Positioning Elements
sanjay2211
 
HTML Forms
Nisa Soomro
 
html-table
Dhirendra Chauhan
 
CSS Positioning and Features of CSS3
Jaimin Brahmbhatt
 

What's hot (20)

PPTX
Java script
Abhishek Kesharwani
 
PPTX
Html formatting
Webtech Learning
 
PPTX
Html tables
Er. Nawaraj Bhandari
 
PPT
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
PDF
Flexbox and Grid Layout
Rachel Andrew
 
PDF
JavaScript - Chapter 11 - Events
WebStackAcademy
 
PPTX
Bootstrap PPT by Mukesh
Mukesh Kumar
 
PPT
jQuery
Mostafa Bayomi
 
PPTX
Javascript 101
Shlomi Komemi
 
PPTX
Css borders
AbhishekMondal42
 
PPTX
Css selectors
Parth Trivedi
 
PPTX
Css floats
Webtech Learning
 
PPT
Css lecture notes
Santhiya Grace
 
PPT
Box Model
Amit Kumar Singh
 
PPTX
Css box-model
Webtech Learning
 
PDF
CSS3 Media Queries
Russ Weakley
 
PPTX
Dom(document object model)
Partnered Health
 
PPTX
Page layout with css
Er. Nawaraj Bhandari
 
PPTX
jQuery
Dileep Mishra
 
PPT
Advanced Cascading Style Sheets
fantasticdigitaltools
 
Java script
Abhishek Kesharwani
 
Html formatting
Webtech Learning
 
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
Flexbox and Grid Layout
Rachel Andrew
 
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Bootstrap PPT by Mukesh
Mukesh Kumar
 
Javascript 101
Shlomi Komemi
 
Css borders
AbhishekMondal42
 
Css selectors
Parth Trivedi
 
Css floats
Webtech Learning
 
Css lecture notes
Santhiya Grace
 
Box Model
Amit Kumar Singh
 
Css box-model
Webtech Learning
 
CSS3 Media Queries
Russ Weakley
 
Dom(document object model)
Partnered Health
 
Page layout with css
Er. Nawaraj Bhandari
 
Advanced Cascading Style Sheets
fantasticdigitaltools
 
Ad

Similar to CSS Positioning Elements.pdf (20)

PDF
Web Design Course: CSS lecture 5
Gheyath M. Othman
 
PDF
Exp13 write up
Ankit Dubey
 
PPTX
Advanced CSS.pptx
DiyonaVas
 
PPTX
CSS Position and it’s values
Gunjan Tulsiani
 
PPTX
Web Programming Basic topic.pptx
ShouravPodder3
 
PPTX
Css position property
AnujRana43
 
PPTX
CSS_Dibbo
Sayanton Vhaduri
 
PPTX
Full Stack Development CSS_Layouts,Grid,FlexboxPPT.pptx
ganeshchettipalli
 
PDF
Emerson Prep: Position Property
Thinkful
 
PPTX
Chapter 15: Floating and Positioning
Steve Guinan
 
PDF
ClaFundamentalsof Web Developmentss12 .pdf
kasperkey106
 
PPTX
CSS_Day_Three (W3schools)
Rafi Haidari
 
PPTX
Castro Chapter 11
Jeff Byrnes
 
PPTX
CSS3 PPT.pptx
AchieversIT
 
PPTX
Designing for the web - 101
Ashraf Hamdy
 
PPTX
Lecture 5 & 6 Advance CSS.pptx for web
ZahraWaheed9
 
PPT
Css advanced – session 4
Dr. Ramkumar Lakshminarayanan
 
PDF
CSS3 Refresher
Ivano Malavolta
 
PDF
Web Development 4 (HTML & CSS)
ghayour abbas
 
Web Design Course: CSS lecture 5
Gheyath M. Othman
 
Exp13 write up
Ankit Dubey
 
Advanced CSS.pptx
DiyonaVas
 
CSS Position and it’s values
Gunjan Tulsiani
 
Web Programming Basic topic.pptx
ShouravPodder3
 
Css position property
AnujRana43
 
CSS_Dibbo
Sayanton Vhaduri
 
Full Stack Development CSS_Layouts,Grid,FlexboxPPT.pptx
ganeshchettipalli
 
Emerson Prep: Position Property
Thinkful
 
Chapter 15: Floating and Positioning
Steve Guinan
 
ClaFundamentalsof Web Developmentss12 .pdf
kasperkey106
 
CSS_Day_Three (W3schools)
Rafi Haidari
 
Castro Chapter 11
Jeff Byrnes
 
CSS3 PPT.pptx
AchieversIT
 
Designing for the web - 101
Ashraf Hamdy
 
Lecture 5 & 6 Advance CSS.pptx for web
ZahraWaheed9
 
Css advanced – session 4
Dr. Ramkumar Lakshminarayanan
 
CSS3 Refresher
Ivano Malavolta
 
Web Development 4 (HTML & CSS)
ghayour abbas
 
Ad

More from Kongu Engineering College, Perundurai, Erode (20)

PPTX
Event Handling -_GET _ POSTimplementation.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
PPTX
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
PPTX
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
PPTX
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
PPT
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
PPT
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
PPTX
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
PPTX
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Bootstarp installation.pptx
Kongu Engineering College, Perundurai, Erode
 
Event Handling -_GET _ POSTimplementation.pptx
Kongu Engineering College, Perundurai, Erode
 
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 

Recently uploaded (20)

PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
PPTX
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
PPTX
easa module 3 funtamental electronics.pptx
tryanothert7
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PPTX
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
PDF
Introduction to Data Science: data science process
ShivarkarSandip
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
easa module 3 funtamental electronics.pptx
tryanothert7
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Inventory management chapter in automation and robotics.
atisht0104
 
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
Introduction to Data Science: data science process
ShivarkarSandip
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 

CSS Positioning Elements.pdf

  • 1. CSS Positioning Elements Dr.T.Abirami Associate Professor Department of IT Kongu Engineering College Perundurai
  • 2. CSS Positioning Elements • The positioning of an element can be done using the top, right, bottom, and left properties. • These specify the distance of an HTML element from the edge of the viewport. • To set the position by using the following properties, we have to declare the positioning method. • Fixed • Static • Relative • Absolute • Sticky CSS helps to position your HTML element. The position property specifies the type of positioning method used for an element (static, relative, absolute, fixed, or sticky).
  • 3. • It always stays in the same place even if the page is scrolled. • The top, right, bottom, and left properties are used to position the element. • The element is positioned relative to the browser window Fixed Positioning
  • 4. Fixed Positioning <html> <head> </head> <body> <div style = "position:fixed; left:80px; top:40px; background-color:yellow;"> This div has fixed positioning. </div> </body> </html>
  • 5. Absolute Positioning • An element with position: absolute is positioned at the specified coordinates relative to your screen top-left corner. • You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document. • The element is positioned relative to its first positioned (not static) ancestor element
  • 6. <html> <head> </head> <body> <div style = "position:absolute; left:80px; top:20px; background- color:yellow;"> This div has absolute positioning. </div> </body> </html>
  • 7. Relative Positioning • The element is positioned relative to its normal position, so "left:20px" adds 20 pixels to the element's LEFT position • An element with position: relative; is positioned relative to its normal position. • Setting the top, right, bottom, and left properties of a relatively- positioned element will cause it to be adjusted away from its normal position. • Other content will not be adjusted to fit into any gap left by the element.
  • 8. <html> <head> <style> div.relative { position: relative; left: 30px; border: 3px solid #73AD21; } </style> </head> <body> <h2>position: relative;</h2> <p>An element with position: relative</p> <div class="relative"> This div element has position: relative; </div> </body> </html>
  • 9. position: static; • HTML elements are positioned static by default. • Static positioned elements are not affected by the top, bottom, left, and right properties. • An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page: • This <div> element has position: static;
  • 10. <html> <head> <style> div.static { position: static; border: 3px solid #73AD21; } </style> </head> <body> <h2>position: static;</h2> <p>An element with position</p> <div class="static"> This div element has position: static; </div> </body> </html>
  • 11. position: sticky; • It is positioned based on the user's scroll position. <html> <head> <style> div.sticky { position: -webkit-sticky; position: sticky; top: 0; padding: 5px; background-color: #cae8ca; border: 2px solid #4CAF50; } </style> </head> <body> <p>Try to <b>scroll</b> inside this frame to understand how sticky positioning works.</p> <div class="sticky">I am sticky!</div> <div style="padding-bottom:2000px"> <p>Scroll back up to remove the stickyness.</p> </div> </body> </html>