SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Introduction:
This tutorial is on how to position elements properly in CSS.
Template:
Here is the default HTML template containing our head and body for our page...
1. <html>
2. <head>
3.
4. </head>
5. <body>
6.
7. </body>
8. </html>
Linking CSS:
Next, if we were going to be using an external (from the editing HTML/PHP file) CSS file, we would want
to link our CSS file in the head tags, like so...
1. <link rel='stylesheet' href='style.css' type='text/css' />
I'm going to be using inline styling in order for it to be easier to read and understand for you, the reader.
Elements:
So now we want to create some test elements. I will create, a header div, a footer div, a content div, and
a sidebar div...
1. <div class='header'>
2. </div>
3. <div class='content'>
4. </div>
5. <div class='sidebar'>
6. </div>
7. <div class='footer'>
8. </div>
We want our head to cover the full width of our content page, at the top. Footer is the same as the header
but at the bottom. Content will be the majority of the middle (vertically) on the left hand side, while we our
sidebar will fill the right side of the page.
Background:
So we can easily tell our divs apart, we are first going to add a background colour to each of them...
1. style='background-color: black;'
My colours;
Header; Blue
Content; Pink
Sidebar; Orange
Footer; Black
Width & Height:
If you test your page, you will get nothing. That is because although our div's are there (check the page
source code), they only have dimensions of 0 x 0 due to not having any content inside of them. We are
going to set the heights and widths appropriately. We want our header to be full width, followed by, let's
say 120pixels (px) height...
1. width: 100%; height: 120px;
Content is not the full width due to the sidebar, we'll put 75% leaving 25%. Height will be 600pixels...
1. width: 75%; height: 600px;
Sidebar is not the full width due to the content, we have 25% left, so we'll use 20% of it leaving 5% as
space, etc. We'll use the same height as the content, therefore keeping the page as a grid layout.
1. width: 20%; height: 600px;
The footer will be the same as the header...
1. width: 100%; height: 120px;
Now test your page. You can see that it's all fine, except our sidebar is under our content div. Not a very
good sidebar, is it?
Siding...?
To make our sidebar 'float' to the right hand side of our page, we'll use the convinient float property, set it
to 'right'...
1. float: right;
We also need our content to be floating left in order to make room for our sidebar floating to the right side
of the page...
1. float: left;
Problems...
Perfect... No? Our header has gone behind our floating divs, and is now directly below the header. Add
'clear:both' to the footer to fix this, so it goes under all floating divs.
1. clear: both;
Finished!

Weitere ähnliche Inhalte

Mehr von zubeditufail

SPMC - Pakistan training iso 14001 EMS awareness
SPMC - Pakistan training iso 14001 EMS awarenessSPMC - Pakistan training iso 14001 EMS awareness
SPMC - Pakistan training iso 14001 EMS awarenesszubeditufail
 
SPMC - Pakistan training iso 9001 QMS awareness
SPMC - Pakistan training iso 9001 QMS awarenessSPMC - Pakistan training iso 9001 QMS awareness
SPMC - Pakistan training iso 9001 QMS awarenesszubeditufail
 
SPMC - Pakistan Training Calendar 2020
SPMC - Pakistan Training Calendar 2020SPMC - Pakistan Training Calendar 2020
SPMC - Pakistan Training Calendar 2020zubeditufail
 
ISO 9001:2015 Life Cycle
ISO 9001:2015 Life Cycle ISO 9001:2015 Life Cycle
ISO 9001:2015 Life Cycle zubeditufail
 
CODEX HACCP Short Introduction
CODEX HACCP Short Introduction CODEX HACCP Short Introduction
CODEX HACCP Short Introduction zubeditufail
 
Pakistan Income Tax Ordinance amendment 2016
Pakistan Income Tax Ordinance amendment 2016Pakistan Income Tax Ordinance amendment 2016
Pakistan Income Tax Ordinance amendment 2016zubeditufail
 
Heat stroke by SPMCpk.com
Heat stroke by SPMCpk.comHeat stroke by SPMCpk.com
Heat stroke by SPMCpk.comzubeditufail
 
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCE
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCEAPPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCE
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCEzubeditufail
 
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)zubeditufail
 
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...zubeditufail
 
Ohsas 18001 self assessment checklist
Ohsas 18001 self assessment checklistOhsas 18001 self assessment checklist
Ohsas 18001 self assessment checklistzubeditufail
 
Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...
Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...
Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...zubeditufail
 
A global standard_for_the_identification_of_key_biodiversity_areas_final_web
A global standard_for_the_identification_of_key_biodiversity_areas_final_webA global standard_for_the_identification_of_key_biodiversity_areas_final_web
A global standard_for_the_identification_of_key_biodiversity_areas_final_webzubeditufail
 
The Daily Dawn newspaper - millineium development goals report - Pakistan
The Daily Dawn newspaper - millineium development goals report - PakistanThe Daily Dawn newspaper - millineium development goals report - Pakistan
The Daily Dawn newspaper - millineium development goals report - Pakistanzubeditufail
 
shehri Letter to sepa
shehri Letter to sepashehri Letter to sepa
shehri Letter to sepazubeditufail
 
EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...
EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...
EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...zubeditufail
 
Eia coal convying at PIBT Port Qasim by NESPAK
Eia coal convying at PIBT Port Qasim by NESPAKEia coal convying at PIBT Port Qasim by NESPAK
Eia coal convying at PIBT Port Qasim by NESPAKzubeditufail
 
TAZ "Two and a Half Minute" - October - 2016
TAZ "Two and a Half Minute" - October - 2016TAZ "Two and a Half Minute" - October - 2016
TAZ "Two and a Half Minute" - October - 2016zubeditufail
 
ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...
ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...
ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...zubeditufail
 
5 ways you can generate your own leads if you don’t have marketing support
5 ways you can generate your own leads if you don’t have marketing support5 ways you can generate your own leads if you don’t have marketing support
5 ways you can generate your own leads if you don’t have marketing supportzubeditufail
 

Mehr von zubeditufail (20)

SPMC - Pakistan training iso 14001 EMS awareness
SPMC - Pakistan training iso 14001 EMS awarenessSPMC - Pakistan training iso 14001 EMS awareness
SPMC - Pakistan training iso 14001 EMS awareness
 
SPMC - Pakistan training iso 9001 QMS awareness
SPMC - Pakistan training iso 9001 QMS awarenessSPMC - Pakistan training iso 9001 QMS awareness
SPMC - Pakistan training iso 9001 QMS awareness
 
SPMC - Pakistan Training Calendar 2020
SPMC - Pakistan Training Calendar 2020SPMC - Pakistan Training Calendar 2020
SPMC - Pakistan Training Calendar 2020
 
ISO 9001:2015 Life Cycle
ISO 9001:2015 Life Cycle ISO 9001:2015 Life Cycle
ISO 9001:2015 Life Cycle
 
CODEX HACCP Short Introduction
CODEX HACCP Short Introduction CODEX HACCP Short Introduction
CODEX HACCP Short Introduction
 
Pakistan Income Tax Ordinance amendment 2016
Pakistan Income Tax Ordinance amendment 2016Pakistan Income Tax Ordinance amendment 2016
Pakistan Income Tax Ordinance amendment 2016
 
Heat stroke by SPMCpk.com
Heat stroke by SPMCpk.comHeat stroke by SPMCpk.com
Heat stroke by SPMCpk.com
 
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCE
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCEAPPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCE
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCE
 
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)
 
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...
 
Ohsas 18001 self assessment checklist
Ohsas 18001 self assessment checklistOhsas 18001 self assessment checklist
Ohsas 18001 self assessment checklist
 
Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...
Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...
Draft2 guiding principles_and_recommendations_for_businesses_in_and_around_kb...
 
A global standard_for_the_identification_of_key_biodiversity_areas_final_web
A global standard_for_the_identification_of_key_biodiversity_areas_final_webA global standard_for_the_identification_of_key_biodiversity_areas_final_web
A global standard_for_the_identification_of_key_biodiversity_areas_final_web
 
The Daily Dawn newspaper - millineium development goals report - Pakistan
The Daily Dawn newspaper - millineium development goals report - PakistanThe Daily Dawn newspaper - millineium development goals report - Pakistan
The Daily Dawn newspaper - millineium development goals report - Pakistan
 
shehri Letter to sepa
shehri Letter to sepashehri Letter to sepa
shehri Letter to sepa
 
EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...
EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...
EIA of Engro Powergen Limited 450 MW RLNG CCPP at PQA, Karachi Sep 29, 2015 b...
 
Eia coal convying at PIBT Port Qasim by NESPAK
Eia coal convying at PIBT Port Qasim by NESPAKEia coal convying at PIBT Port Qasim by NESPAK
Eia coal convying at PIBT Port Qasim by NESPAK
 
TAZ "Two and a Half Minute" - October - 2016
TAZ "Two and a Half Minute" - October - 2016TAZ "Two and a Half Minute" - October - 2016
TAZ "Two and a Half Minute" - October - 2016
 
ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...
ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...
ESIA 132kV Underground Single Circuit Transmission Line from Creek City Grid ...
 
5 ways you can generate your own leads if you don’t have marketing support
5 ways you can generate your own leads if you don’t have marketing support5 ways you can generate your own leads if you don’t have marketing support
5 ways you can generate your own leads if you don’t have marketing support
 

Kürzlich hochgeladen

办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMartaLoveguard
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 

Kürzlich hochgeladen (20)

办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptx
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 

Introduction to css positioning

  • 1. Introduction: This tutorial is on how to position elements properly in CSS. Template: Here is the default HTML template containing our head and body for our page... 1. <html> 2. <head> 3. 4. </head> 5. <body> 6. 7. </body> 8. </html> Linking CSS: Next, if we were going to be using an external (from the editing HTML/PHP file) CSS file, we would want to link our CSS file in the head tags, like so... 1. <link rel='stylesheet' href='style.css' type='text/css' /> I'm going to be using inline styling in order for it to be easier to read and understand for you, the reader. Elements: So now we want to create some test elements. I will create, a header div, a footer div, a content div, and a sidebar div... 1. <div class='header'> 2. </div> 3. <div class='content'> 4. </div> 5. <div class='sidebar'> 6. </div> 7. <div class='footer'> 8. </div> We want our head to cover the full width of our content page, at the top. Footer is the same as the header but at the bottom. Content will be the majority of the middle (vertically) on the left hand side, while we our sidebar will fill the right side of the page. Background: So we can easily tell our divs apart, we are first going to add a background colour to each of them... 1. style='background-color: black;' My colours; Header; Blue Content; Pink Sidebar; Orange Footer; Black Width & Height: If you test your page, you will get nothing. That is because although our div's are there (check the page
  • 2. source code), they only have dimensions of 0 x 0 due to not having any content inside of them. We are going to set the heights and widths appropriately. We want our header to be full width, followed by, let's say 120pixels (px) height... 1. width: 100%; height: 120px; Content is not the full width due to the sidebar, we'll put 75% leaving 25%. Height will be 600pixels... 1. width: 75%; height: 600px; Sidebar is not the full width due to the content, we have 25% left, so we'll use 20% of it leaving 5% as space, etc. We'll use the same height as the content, therefore keeping the page as a grid layout. 1. width: 20%; height: 600px; The footer will be the same as the header... 1. width: 100%; height: 120px; Now test your page. You can see that it's all fine, except our sidebar is under our content div. Not a very good sidebar, is it? Siding...? To make our sidebar 'float' to the right hand side of our page, we'll use the convinient float property, set it to 'right'... 1. float: right; We also need our content to be floating left in order to make room for our sidebar floating to the right side of the page... 1. float: left; Problems... Perfect... No? Our header has gone behind our floating divs, and is now directly below the header. Add 'clear:both' to the footer to fix this, so it goes under all floating divs. 1. clear: both; Finished!