Movatterモバイル変換


[0]ホーム

URL:


Uploaded byzubeditufail
DOCX, PDF165 views

Html n css tutorial

This document provides a two-part tutorial on creating a basic webpage with HTML and CSS. The first part covers the HTML structure, including adding divs for the header, content, sidebar, and footer. The second part covers styling the HTML elements with CSS, including setting widths, heights, colors and positioning for each section. Styling is applied to elements like the wrapper, header, content, sidebar and footer. The tutorial provides the necessary CSS code to style each element and position them on the page. Once completed, the basic webpage structure and styling is finished but no actual content is added yet.

Embed presentation

Download to read offline
Basic HTML/CSS WebPage Part 1 - HTMLSubmittedby:YorkiebarSaturday,April 5, 2014 - 08:26Language:HTML/CSSIntroduction:Thistutorial isgoingto be the firstof two basicparts on how to create a basic webpage withtheessential componentsusingpure HTML and CSS.The Structure:Our webpage isgoingto consistof a headercoveringthe full widthof contentatthe topof the page,abodysectioncoveringmostof the wide fromheadertofairlyfardownthe page,a side barcontainingwidgetsonthe righthand side of the page - nexttothe mainbodysectionof the page,and a footcoveringthe same width(andprobablyheight)asthe headersection;underneathourbodyandside barsections.ThisPart:Thispart is goingto be on the HTML (HypertextMarkupLanguage),the secondpartisgoingto be onstylingthe componentsinCSS(Cascade Style Sheets).Main HTML File:Firstwe want to define abasicHTML file,itneedsthe doctype,html andbodytags...<!DOCTYPE><html><head></head><body></body></html>Head:For those of you whohave notusedHTML before,the headtagsare usedto containthingslike imports,requiresandexternal references,while the bodysection of tagsisusedtoholdthe displayandgraphicsinformationsuchasthe headers,footers,images,etc.For thispage we are goingto be usinga CSS file inthe nextpartso we'll firstinclude thatfile(it'snotyetcreatedthoughbut still shouldn'tgive usanymajor,website breakingerrors)...<head><link rel='stylesheet' href='style.css' type='text/css'></head>We reference afile named'style.css'withinthe same directoryasthe file the code iscontainedin(index.html).We'llcreate thisinthe nextpart.Nextwe are goingto give our page a title,thiswill show upinthe tab/windowframe of the webpage...<head><link rel='stylesheet' href='style.css' type='text/css'><title>My Basic Webpage</title></head>Body:Nextwe are goingto want to create the mainbodysectionof the page.We are goingto use divsas thetype of contentholdertagsfor separatingoursectionsout.Divs - or Divisions - are usedto holdfair
amountsof data, splitthemupin to easilyreadableandusable sections,aswell asbeingable toholdotherHTML tags withinthem.The other thingyouwill needtoknowaboutare classesandIDs. ClassesandIDs are usedinCSS to pairthe stylinggivenwithwherethe stylingshouldbe appliedtowithinthe givenHTML/Jade/PHPfiles.AnyHTML tag can have a CSS ID or Class.Classesare supposedtobe usedforstylingthatisusedmore thanonce and for importantcomponentswithinfileswhile IDsare supposedtobe usedforsingularitemsthat onlyexistonce withinafile - suchas an article withaspecifictitle,the idcouldbe the title becauseit wouldn'tcome upagainwhereasthe classcouldbe 'article'because articleswouldbe usedmultipletimesandtheywouldhave touse the same styling.So firstwe move into our bodysection,betweenthe openingandclosingbodytagsandtype twonewdivs,one fora wrapperand the otherfor our header.We give themthe appropriate classnames...<body><div class='wrapper'><div class='header'></div></div></body>Next,underneaththe headerwe wanttocreate a bodysection,I've namedthe class'content'...<body><div class='wrapper'><div class='header'></div><div class='content'></div></div></body>Nowwe create a side barsection,the classname isset to 'side'...<body><div class='wrapper'><div class='header'></div><div class='content'></div><div class='side'></div></div></body>Andfinally,we create afootersectionwithaclassname of 'footer'...<body><div class='wrapper'><div class='header'></div><div class='content'></div><div class='side'></div><div class='footer'></div></div></body>
We encase all of our sectionsinthe wrapperdivbecause we are goingtouse the wrapperdivtoset theboundarieson-screenforthe restof the componentsof the webpage.Classand ID namescan be set towhateveriseasiestforyou,the developerbutmustbe rememberedoreasilyfound/relatedtowhenusingthemlaterontostyle the elements.NextTutorial:Nexttutorial we are goingto be stylingthese elementsusingourstyle.cssfile whichwe will createwithinthattutorial.Basic HTML/CSS Web Page Part 2 - CSSSubmitted by:YorkiebarSunday, April 6, 2014 - 18:43Language:HTML/CSSVisitors have accessed this post 65 times.Introduction:This tutorial is going to be the second of two basic parts on how to create a basic web page withthe essential components using pure HTML and CSS.The Structure:Our web page is going to consist of a header covering the full width of content at the top of thepage, a body section covering most of the wide from header to fairly far down the page, a sidebar containing widgets on the right hand side of the page - next to the main body section of thepage, and a foot covering the same width (and probably height) as the header section;underneath our body and side bar sections.This Part:The first part was on the HTML (Hypertext Markup Language), this second part is going to be onstyling the components in CSS (Cascade Style Sheets).All Components:First we want to ensure that all the components have our default styling instead of the browsersdefault styling that the user is currently using to access the webpage. We do thsi by setting theall components property which is a star/an asterix (*)...1. * {2. padding: 0px;3. margin: 0px;4. font-size: 18px;5. font-color: #0a0a0a;6. font-family: Verdana;7. }We give all the components a default value of no padding or margin (no white space or extraspace), and a default font size, colour and family. (Note; Colour must be spelt the american way(color)).We set the default properties for all the components at once because it makes it easier for uslater on without having to re-type the same property code for many different components.HTML:This part is not really needed but we also set the html tags to have a full 100% width of theentire browsing window and a default height (it should stop wherever the components do)...
1. html {2. width: 100%;3. height: auto;4. }Wrapper:Next we have the wrapper class. This wrapper class, as mentioned in the previous tutorial, isgoing to set the boundaries for the rest of the components. Since we want the rest of thecomponents to center on the page (within reason of course), we are going to give this wrapperclass div a width of just 980px (essentially the most commonly used desktop width) and center itin to the middle of the 100% browser width html tags...1. .wrapper {2. width: 980px;3. margin: 0px auto;4. background-color: #ccc;5. }We center the wrapper class by giving it a margin of '0px auto', this sets the top and bottom to0px white space/extra space, and the left and right sides to auto - which means they have to bethe same, and are therefore centering the container.Header:Now we need to style the header. As you can see, we set the wrappers background colour tohex code #ccc which is a light grey. We are going to set the header to have a width of 980px aswell, center it in the wrapper container div and give it a background colour of black...1. .header {2. width: 980px;3. height: 80px;4. background-color: black;5. margin: 0px auto;6. }We also set a height property on the header class because we want to be able to see it withoutcontent. By default, the height and width properties are set to auto which means they will onlygo as big as they need to be, so since we have no content within the divs, they would not showup at all.Content:Now we have the content div. Instead of giving this one a full 980px browser width of the page,we want it to stand by the side of the side bar so we set the content to 700px width, giving280px spare space to use.1. .content {2. width: 700px;3. min-height: 450px;4. float: left;5. background-color: blue;6. margin: 0px auto;7. }We also float the content block left which means it will go as far left as possible and othercontainers have the ability to be inline with or go past it.The background colour of this content section is blue.
Side:The side bar fills up the rest of the space next to the content section. This section has 260pxbrowser width, which added with the 700px browser width of the content container, gives us atotal of 960px used giving 20px spare. So we use this 20px to separate the two sections bygiving this side bar a 20px padding on the left of it.1. .side {2. width: 260px;3. min-height: 450px;4. padding-left: 20px;5. float: right;6. background-color: red;7. margin: 0px auto;8. }Again, we set a default minimum height, the same as the content container since we may wantthem to be the same size at a minimum to make the page look like it has a nice grid like layout.The background colour of the side bar is red.Footer:Finally we have the footer container, this footer has the properties we've seen in all the previouscomponents but there is one new one, that is 'clear: both;'.Clear both means that the floats that occured above the section that has the clear:both sectionno longer affect the components. This means that it will go with the grid like layout. Whereas ifwe didn't have this clear both property on the footer, it would simply go and hide behind thecontent and side bar containers - try it out, remove the line and refresh your index.html page.1. .footer {2. clear: both;3. width: 980px;4. height: 80px;5. background-color: black;6. margin: 0px auto;7. }Finished, But...So that is the basic two part tutorial series of setting up a basic HTML and CSS webpage, butas you can see, it has no content and doesn't look very nice. I've used the different bold coloursto easily show you exactly where the boundaries of each section begin and end.So, I will almost definitely make another few tutorials on how to make them look nice, addcontent and make them flow with each other. If you look forward to seeing them, make sure tocheck my tracking on my account/profile page to see if they have been posted yet, or check outany of my other thread posts.Thanks for reading!

Recommended

PDF
Recipe book flipped-coding
PPTX
CSS Layout Tutorial
 
PPT
Easy Guide to WordPress Theme Integration
DOC
Class 2 handout css exercises (2)
PDF
Designing for magento
PDF
Installing And Configuration for your Wordpress blog
PPTX
Abstracting functionality with centralised content
PDF
ACTC 2013 Website Building Notes
PPT
Designer toolkit
DOCX
Basic CSS concepts by naveen kumar veligeti
PPT
Chapter8
PPT
Designer toolkit
PDF
Introduction to-concrete-5
PDF
Introduction to-concrete-5
PPTX
10 WordPress Theme Hacks to Improve Your Site
PDF
CSS: a rapidly changing world
PPTX
Day of code
PPTX
How to Create simple One Page site
PDF
Creative Web 02 - HTML & CSS Basics
PDF
Abbottabad State of Environment and Development Plan
PDF
E book puttingthecustomer_atthecenter_accountplanningstrategies_togrowrevenue...
PDF
Manual on Labor-Management Relations: Japanese Experiences and Best Practices
PDF
Ports Australia
PDF
Chitral - Integrated Development Vision
PDF
Brief SINDH AGRICULTURAL GROWTH PROJECT (SAGP)
PDF
Sea workshop report Pakistan
PDF
Simplified Resource Manual to Support Application of the Protocol on Strategi...
PDF
1725 file sea_manual
PDF
Zorlu pakistan eia april 2010
PDF
African Development Bank Strategic Impact Assessment Guidelines Final Report

More Related Content

PDF
Recipe book flipped-coding
PPTX
CSS Layout Tutorial
 
PPT
Easy Guide to WordPress Theme Integration
DOC
Class 2 handout css exercises (2)
PDF
Designing for magento
PDF
Installing And Configuration for your Wordpress blog
PPTX
Abstracting functionality with centralised content
PDF
ACTC 2013 Website Building Notes
Recipe book flipped-coding
CSS Layout Tutorial
 
Easy Guide to WordPress Theme Integration
Class 2 handout css exercises (2)
Designing for magento
Installing And Configuration for your Wordpress blog
Abstracting functionality with centralised content
ACTC 2013 Website Building Notes

What's hot

PPT
Designer toolkit
DOCX
Basic CSS concepts by naveen kumar veligeti
PPT
Chapter8
PPT
Designer toolkit
PDF
Introduction to-concrete-5
PDF
Introduction to-concrete-5
PPTX
10 WordPress Theme Hacks to Improve Your Site
PDF
CSS: a rapidly changing world
PPTX
Day of code
PPTX
How to Create simple One Page site
PDF
Creative Web 02 - HTML & CSS Basics
Designer toolkit
Basic CSS concepts by naveen kumar veligeti
Chapter8
Designer toolkit
Introduction to-concrete-5
Introduction to-concrete-5
10 WordPress Theme Hacks to Improve Your Site
CSS: a rapidly changing world
Day of code
How to Create simple One Page site
Creative Web 02 - HTML & CSS Basics

Viewers also liked

PDF
Abbottabad State of Environment and Development Plan
PDF
E book puttingthecustomer_atthecenter_accountplanningstrategies_togrowrevenue...
PDF
Manual on Labor-Management Relations: Japanese Experiences and Best Practices
PDF
Ports Australia
PDF
Chitral - Integrated Development Vision
PDF
Brief SINDH AGRICULTURAL GROWTH PROJECT (SAGP)
PDF
Sea workshop report Pakistan
PDF
Simplified Resource Manual to Support Application of the Protocol on Strategi...
PDF
1725 file sea_manual
PDF
Zorlu pakistan eia april 2010
PDF
African Development Bank Strategic Impact Assessment Guidelines Final Report
PDF
13ways to inspire your audience
PDF
IFC - PROMOTING ENVIRONMENTAL AND SOCIAL RISK MANAGEMENT (ESRM) IN THE FINANC...
DOC
Environment challanges-and-response-of-pakistan
PDF
UNECE Protocol on Strategic Environmental Assessment (SEA) - An Introduction
Abbottabad State of Environment and Development Plan
E book puttingthecustomer_atthecenter_accountplanningstrategies_togrowrevenue...
Manual on Labor-Management Relations: Japanese Experiences and Best Practices
Ports Australia
Chitral - Integrated Development Vision
Brief SINDH AGRICULTURAL GROWTH PROJECT (SAGP)
Sea workshop report Pakistan
Simplified Resource Manual to Support Application of the Protocol on Strategi...
1725 file sea_manual
Zorlu pakistan eia april 2010
African Development Bank Strategic Impact Assessment Guidelines Final Report
13ways to inspire your audience
IFC - PROMOTING ENVIRONMENTAL AND SOCIAL RISK MANAGEMENT (ESRM) IN THE FINANC...
Environment challanges-and-response-of-pakistan
UNECE Protocol on Strategic Environmental Assessment (SEA) - An Introduction

Similar to Html n css tutorial

PPTX
Css for Development
PPTX
Layouts
PDF
css-tutorial
PDF
css-tutorial
PPTX
Intermediate Web Design
PPTX
Cascading Style Sheets
PDF
3 coding101 fewd_lesson3_your_first_website 20210105
PPTX
css-note.pptx
PPT
Cascading style sheet
PPTX
[SUTD GDSC] Intro to HTML and CSS
PPTX
CSS presentation for beginners where they can understand easily
 
PPTX
css front end development , designing web page
 
PPT
CSS Lesson 1.ppt Cascading Style Sheet Stylesheet Language
PDF
Design and CSS
PDF
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
PPTX
Cascading style sheet
PPT
Chapter6
PPT
Introduction to CSS in HTML.ppt
PPTX
CSS Walktrough Internship Course
Css for Development
Layouts
css-tutorial
css-tutorial
Intermediate Web Design
Cascading Style Sheets
3 coding101 fewd_lesson3_your_first_website 20210105
css-note.pptx
Cascading style sheet
[SUTD GDSC] Intro to HTML and CSS
CSS presentation for beginners where they can understand easily
 
css front end development , designing web page
 
CSS Lesson 1.ppt Cascading Style Sheet Stylesheet Language
Design and CSS
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Cascading style sheet
Chapter6
Introduction to CSS in HTML.ppt
CSS Walktrough Internship Course

More from zubeditufail

PDF
National Disaster Risk Reduction Policy 2012.pdf
PDF
UNDRR Disaster Risk Reduction in Pakistan
PDF
Pakistan Framework-for-Implementation-of-CC-Policy-2014-2030
PDF
Pakistan Updated Nationally Determined Contributions - 2021
PDF
Pk National Disaster Risk Reduction Strategy 2025 - 2030.pdf
PDF
International Environmental Impact Assessment - Atkins.pdf
PDF
The Holy Quran with Easy Word Meaning
DOCX
Use of fungus bricks in construction sector
PDF
SPMC training iso 45001 awareness
PDF
SPMC - Pakistan training iso 14001 EMS awareness
PDF
SPMC - Pakistan training iso 9001 QMS awareness
PDF
SPMC - Pakistan Training Calendar 2020
PDF
ISO 9001:2015 Life Cycle
PDF
CODEX HACCP Short Introduction
PDF
Pakistan Income Tax Ordinance amendment 2016
PDF
Heat stroke by SPMCpk.com
PDF
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCE
PDF
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)
PDF
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...
PDF
Ohsas 18001 self assessment checklist
National Disaster Risk Reduction Policy 2012.pdf
UNDRR Disaster Risk Reduction in Pakistan
Pakistan Framework-for-Implementation-of-CC-Policy-2014-2030
Pakistan Updated Nationally Determined Contributions - 2021
Pk National Disaster Risk Reduction Strategy 2025 - 2030.pdf
International Environmental Impact Assessment - Atkins.pdf
The Holy Quran with Easy Word Meaning
Use of fungus bricks in construction sector
SPMC training iso 45001 awareness
SPMC - Pakistan training iso 14001 EMS awareness
SPMC - Pakistan training iso 9001 QMS awareness
SPMC - Pakistan Training Calendar 2020
ISO 9001:2015 Life Cycle
CODEX HACCP Short Introduction
Pakistan Income Tax Ordinance amendment 2016
Heat stroke by SPMCpk.com
APPLICATION IN FORM - I FOR PRIOR ENVIRONMENTAL CLEARANCE
Resettlement Policy Framework - Karachi Neighborhood Improvement Project (KNIP)
Environmental and Social Management Framework (ESMF) - Karachi Neighborhood I...
Ohsas 18001 self assessment checklist

Recently uploaded

PDF
Database Management Systems(DBMS):UNIT-I Introduction to Database(DBMS) BCA S...
PDF
How Modern Custom Software is Revolutionizing Mortgage Lending Processes -Ma...
PDF
Operating System (OS) :UNIT-I Introduction to Operating System BCA SEP SEM-II...
PPTX
GDS Integration Solution | GDS Integration Service
PDF
SecureChain AI (SCAI) Token – Smart Contract Security Audit Report by EtherAu...
PPTX
Managed Splunk Partner vs In-House: Cost, Risk & Value Comparison
PDF
Imed Eddine Bouchoucha | computer engineer | software Architect
PDF
Cloud-Based Underwriting Software for Insurance
PDF
Data structure using C :UNIT-I Introduction to Data structures and Stacks BCA...
PDF
KoderXpert – Odoo, Web & AI Solutions for Growing Businesses
PDF
Why Zoho Notebook’s AI-Fueled Upgrade Matters for Knowledge Workers in 2026
PPTX
NSF Converter Software to Convert NSF to PST, EML, MSG
PPTX
application security presentation 2 by harman
PDF
What Is A Woman (WIAW) Token – Smart Contract Security Audit Report by EtherA...
PDF
Red Hat Summit 2025 - Triton GPU Kernel programming.pdf
PDF
Advanced Prompt Engineering: The Art and Science
PDF
Intelligent CRM for Insurance Brokers: Managing Clients with Precision
PDF
Navigating SEC Regulations for Crypto Exchanges Preparing for a Compliant Fut...
PDF
IT Estate Modernization: Transform Your Infrastructure for the Future .pdf
PPTX
Application Security – Static Application Security Testing (SAST)
Database Management Systems(DBMS):UNIT-I Introduction to Database(DBMS) BCA S...
How Modern Custom Software is Revolutionizing Mortgage Lending Processes -Ma...
Operating System (OS) :UNIT-I Introduction to Operating System BCA SEP SEM-II...
GDS Integration Solution | GDS Integration Service
SecureChain AI (SCAI) Token – Smart Contract Security Audit Report by EtherAu...
Managed Splunk Partner vs In-House: Cost, Risk & Value Comparison
Imed Eddine Bouchoucha | computer engineer | software Architect
Cloud-Based Underwriting Software for Insurance
Data structure using C :UNIT-I Introduction to Data structures and Stacks BCA...
KoderXpert – Odoo, Web & AI Solutions for Growing Businesses
Why Zoho Notebook’s AI-Fueled Upgrade Matters for Knowledge Workers in 2026
NSF Converter Software to Convert NSF to PST, EML, MSG
application security presentation 2 by harman
What Is A Woman (WIAW) Token – Smart Contract Security Audit Report by EtherA...
Red Hat Summit 2025 - Triton GPU Kernel programming.pdf
Advanced Prompt Engineering: The Art and Science
Intelligent CRM for Insurance Brokers: Managing Clients with Precision
Navigating SEC Regulations for Crypto Exchanges Preparing for a Compliant Fut...
IT Estate Modernization: Transform Your Infrastructure for the Future .pdf
Application Security – Static Application Security Testing (SAST)

Html n css tutorial

  • 1.
    Basic HTML/CSS WebPagePart 1 - HTMLSubmittedby:YorkiebarSaturday,April 5, 2014 - 08:26Language:HTML/CSSIntroduction:Thistutorial isgoingto be the firstof two basicparts on how to create a basic webpage withtheessential componentsusingpure HTML and CSS.The Structure:Our webpage isgoingto consistof a headercoveringthe full widthof contentatthe topof the page,abodysectioncoveringmostof the wide fromheadertofairlyfardownthe page,a side barcontainingwidgetsonthe righthand side of the page - nexttothe mainbodysectionof the page,and a footcoveringthe same width(andprobablyheight)asthe headersection;underneathourbodyandside barsections.ThisPart:Thispart is goingto be on the HTML (HypertextMarkupLanguage),the secondpartisgoingto be onstylingthe componentsinCSS(Cascade Style Sheets).Main HTML File:Firstwe want to define abasicHTML file,itneedsthe doctype,html andbodytags...<!DOCTYPE><html><head></head><body></body></html>Head:For those of you whohave notusedHTML before,the headtagsare usedto containthingslike imports,requiresandexternal references,while the bodysection of tagsisusedtoholdthe displayandgraphicsinformationsuchasthe headers,footers,images,etc.For thispage we are goingto be usinga CSS file inthe nextpartso we'll firstinclude thatfile(it'snotyetcreatedthoughbut still shouldn'tgive usanymajor,website breakingerrors)...<head><link rel='stylesheet' href='style.css' type='text/css'></head>We reference afile named'style.css'withinthe same directoryasthe file the code iscontainedin(index.html).We'llcreate thisinthe nextpart.Nextwe are goingto give our page a title,thiswill show upinthe tab/windowframe of the webpage...<head><link rel='stylesheet' href='style.css' type='text/css'><title>My Basic Webpage</title></head>Body:Nextwe are goingto want to create the mainbodysectionof the page.We are goingto use divsas thetype of contentholdertagsfor separatingoursectionsout.Divs - or Divisions - are usedto holdfair
  • 2.
    amountsof data, splitthemupinto easilyreadableandusable sections,aswell asbeingable toholdotherHTML tags withinthem.The other thingyouwill needtoknowaboutare classesandIDs. ClassesandIDs are usedinCSS to pairthe stylinggivenwithwherethe stylingshouldbe appliedtowithinthe givenHTML/Jade/PHPfiles.AnyHTML tag can have a CSS ID or Class.Classesare supposedtobe usedforstylingthatisusedmore thanonce and for importantcomponentswithinfileswhile IDsare supposedtobe usedforsingularitemsthat onlyexistonce withinafile - suchas an article withaspecifictitle,the idcouldbe the title becauseit wouldn'tcome upagainwhereasthe classcouldbe 'article'because articleswouldbe usedmultipletimesandtheywouldhave touse the same styling.So firstwe move into our bodysection,betweenthe openingandclosingbodytagsandtype twonewdivs,one fora wrapperand the otherfor our header.We give themthe appropriate classnames...<body><div class='wrapper'><div class='header'></div></div></body>Next,underneaththe headerwe wanttocreate a bodysection,I've namedthe class'content'...<body><div class='wrapper'><div class='header'></div><div class='content'></div></div></body>Nowwe create a side barsection,the classname isset to 'side'...<body><div class='wrapper'><div class='header'></div><div class='content'></div><div class='side'></div></div></body>Andfinally,we create afootersectionwithaclassname of 'footer'...<body><div class='wrapper'><div class='header'></div><div class='content'></div><div class='side'></div><div class='footer'></div></div></body>
  • 3.
    We encase allof our sectionsinthe wrapperdivbecause we are goingtouse the wrapperdivtoset theboundarieson-screenforthe restof the componentsof the webpage.Classand ID namescan be set towhateveriseasiestforyou,the developerbutmustbe rememberedoreasilyfound/relatedtowhenusingthemlaterontostyle the elements.NextTutorial:Nexttutorial we are goingto be stylingthese elementsusingourstyle.cssfile whichwe will createwithinthattutorial.Basic HTML/CSS Web Page Part 2 - CSSSubmitted by:YorkiebarSunday, April 6, 2014 - 18:43Language:HTML/CSSVisitors have accessed this post 65 times.Introduction:This tutorial is going to be the second of two basic parts on how to create a basic web page withthe essential components using pure HTML and CSS.The Structure:Our web page is going to consist of a header covering the full width of content at the top of thepage, a body section covering most of the wide from header to fairly far down the page, a sidebar containing widgets on the right hand side of the page - next to the main body section of thepage, and a foot covering the same width (and probably height) as the header section;underneath our body and side bar sections.This Part:The first part was on the HTML (Hypertext Markup Language), this second part is going to be onstyling the components in CSS (Cascade Style Sheets).All Components:First we want to ensure that all the components have our default styling instead of the browsersdefault styling that the user is currently using to access the webpage. We do thsi by setting theall components property which is a star/an asterix (*)...1. * {2. padding: 0px;3. margin: 0px;4. font-size: 18px;5. font-color: #0a0a0a;6. font-family: Verdana;7. }We give all the components a default value of no padding or margin (no white space or extraspace), and a default font size, colour and family. (Note; Colour must be spelt the american way(color)).We set the default properties for all the components at once because it makes it easier for uslater on without having to re-type the same property code for many different components.HTML:This part is not really needed but we also set the html tags to have a full 100% width of theentire browsing window and a default height (it should stop wherever the components do)...
  • 4.
    1. html {2.width: 100%;3. height: auto;4. }Wrapper:Next we have the wrapper class. This wrapper class, as mentioned in the previous tutorial, isgoing to set the boundaries for the rest of the components. Since we want the rest of thecomponents to center on the page (within reason of course), we are going to give this wrapperclass div a width of just 980px (essentially the most commonly used desktop width) and center itin to the middle of the 100% browser width html tags...1. .wrapper {2. width: 980px;3. margin: 0px auto;4. background-color: #ccc;5. }We center the wrapper class by giving it a margin of '0px auto', this sets the top and bottom to0px white space/extra space, and the left and right sides to auto - which means they have to bethe same, and are therefore centering the container.Header:Now we need to style the header. As you can see, we set the wrappers background colour tohex code #ccc which is a light grey. We are going to set the header to have a width of 980px aswell, center it in the wrapper container div and give it a background colour of black...1. .header {2. width: 980px;3. height: 80px;4. background-color: black;5. margin: 0px auto;6. }We also set a height property on the header class because we want to be able to see it withoutcontent. By default, the height and width properties are set to auto which means they will onlygo as big as they need to be, so since we have no content within the divs, they would not showup at all.Content:Now we have the content div. Instead of giving this one a full 980px browser width of the page,we want it to stand by the side of the side bar so we set the content to 700px width, giving280px spare space to use.1. .content {2. width: 700px;3. min-height: 450px;4. float: left;5. background-color: blue;6. margin: 0px auto;7. }We also float the content block left which means it will go as far left as possible and othercontainers have the ability to be inline with or go past it.The background colour of this content section is blue.
  • 5.
    Side:The side barfills up the rest of the space next to the content section. This section has 260pxbrowser width, which added with the 700px browser width of the content container, gives us atotal of 960px used giving 20px spare. So we use this 20px to separate the two sections bygiving this side bar a 20px padding on the left of it.1. .side {2. width: 260px;3. min-height: 450px;4. padding-left: 20px;5. float: right;6. background-color: red;7. margin: 0px auto;8. }Again, we set a default minimum height, the same as the content container since we may wantthem to be the same size at a minimum to make the page look like it has a nice grid like layout.The background colour of the side bar is red.Footer:Finally we have the footer container, this footer has the properties we've seen in all the previouscomponents but there is one new one, that is 'clear: both;'.Clear both means that the floats that occured above the section that has the clear:both sectionno longer affect the components. This means that it will go with the grid like layout. Whereas ifwe didn't have this clear both property on the footer, it would simply go and hide behind thecontent and side bar containers - try it out, remove the line and refresh your index.html page.1. .footer {2. clear: both;3. width: 980px;4. height: 80px;5. background-color: black;6. margin: 0px auto;7. }Finished, But...So that is the basic two part tutorial series of setting up a basic HTML and CSS webpage, butas you can see, it has no content and doesn't look very nice. I've used the different bold coloursto easily show you exactly where the boundaries of each section begin and end.So, I will almost definitely make another few tutorials on how to make them look nice, addcontent and make them flow with each other. If you look forward to seeing them, make sure tocheck my tracking on my account/profile page to see if they have been posted yet, or check outany of my other thread posts.Thanks for reading!

[8]ページ先頭

©2009-2025 Movatter.jp