尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
The Basics of Cascading Style Sheets (CSS) Irina McGuire Graphic Designer | Front-End Web Developer www.irinamcguire.com December 3, 2010
Introduction ,[object Object],[object Object],[object Object],Examples of beautiful CSS Web sites: www.csszengarden.com One content, many layouts .
Presentation Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is CSS? CSS stands for  Cascading Style Sheet .  Typical CSS file is a text file with an extention .css  and contains a series of commands or rules.  These rules tell the HTML how to display. *To create a style sheet, create a file using Notepad (PC) or Text Edit (Mac), save it as a .css document and start writing the CSS code (see right). /* Styles for sitename.com*/  body { font-family:Arial;  background: #000; } #container { text-align:left; width:1020px; } #header { height:232px; } #footer { width: 100%; padding: 0 10px; margin-bottom: 10px; } And so on…. Style.css
CSS Benefits ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTML Without CSS “ HTML without CSS is like a piece of candy without a pretty wrapper.” Without CSS, HTML elements typically flow from top to bottom of the page and position themselves to the left by default. With CSS help, we can create containers or DIVs to better organize content  and make a Web page visually appealing.
HTML & CSS ,[object Object],[object Object],[object Object]
The Box Model CSS works on the box model. A typical Web page consists of many boxes joined together from top to bottom. These boxes can be stacked, nested, and can float. Header Navigation Content Footer
Attaching a Style Sheet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CSS Rule Structure A CSS RULE is made up of a selector and a declaration. A declaration consists of property and value. selector  { property: value; } declaration
Selectors body   { property :  value ;  }  h1  { property :  value ;  }  em  { property :  value ;  }  p  { property :  value ;  }  A selector, here in  green , is often an element of HTML.
Properties and Values body { background: purple; }  h1 { color: green;  } h2 { font-size: large; } p { color: #ff0000;}  /*hexadecimal for red*/ body { background: purple; color: green; } Properties and values tell an HTML element how to display. *CSS code can be written in a linear format (above) or in a block format (below).
Grouping Selectors  h1  {color: black;} h1  {font-weight: bold;} h1  {background: white;} h1  { color: black;  font-weight: bold;  background: white; } Group  the same selector  with different declarations together on one line. Example of grouping selectors (both are correct):
Grouping Selectors Group  different selectors  with the same declaration on one line. h1 { color: yellow; } h2 { color: yellow; } h3 { color: yellow; } h1, h2, h3 { color: yellow; } Example of grouping selectors (both are correct):
Comments in CSS ,[object Object],[object Object],[object Object],[object Object],p { color: #ff0000;}  /*Company Branding*/
Typical Web Page (Browser) header footer main menu Container
Typical Web Page (HTML) <div id=“ container ”> <div id=“ header ”>Insert Title</div> <div id=“ main &quot;>content <div id=“ menu ”>content</div> </div> <div id=“ footer ”>content</div> </div> Typical HTML Web page is made up of containers (boxes) or DIVs. Each DIV is assigned an ID or a Class.
Typical Web Page (CSS) # container  {property: value;}  # menu  {property: value;}  # main  {property: value;}  # footer  {property: value;}  The CSS file uses the same DIV/ID/Class names as the HTML and uses them to style the elements.
IDs and Classes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CSS Box Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTML    CSS div id=“header” div id=“footer” div id=“content” # content  { background-color: #ccc; margin-bottom: 10px; border: 1px dashed blue; color: #fff; width: auto; }
Common CSS Layout Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],width height padding margin border
Width & Height div id=“box” #box {width=“50px”} #box {width=“50em”}  #box {width=“100%”} #box {width=“auto”}  Width and height define the width and height of an element. #box {height=“auto”}  *Width and height can be specified in pixels, ems, percentages or set to auto
Float: (left, right) Float property makes elements float to the right or left of the screen, positioned where they are in the HTML.  Floating allows word wrapping.  div id=“box” Here is some text which wraps around the box floated to the left. #box {float:left; margin-right: 10px;}
Clear: (left, right, both) #box3 { background-color: white; border:   1px solid #000; clear: both;}  When elements are floated, they wrap around each other to form a “caravan.” The  clear  property detaches an element from the “caravan” and allows it to start on a new line. div id=“box1” div id=“box2” div id=“box3”
Border (top, right, bottom, left) #box {  border-color: red;  border-style: dotted;  border-width: 2px; div id=“box” #box {  border: red dotted 1px; #box { border-top: red dotted 1px; border-bottom: red dotted 1px; border-left: red dotted 1px; border-right: red dotted 1px; } You can define the entire border or only the top, bottom, left, or right. You can also define the border using one declaration. The code could be any of the following:
Padding (top, right, bottom, left) Padding is the space between the text/content and the border. You can use padding for all around the element or specify each side of the rectangle separately. The code could be any of the following: padding: 10px; Padding: 10px 10px; padding: 10px 10px 10px 10px; padding-left: 10px; padding-right: 10px; padding-bottom: 10px; padding-top: 10px; div id=“box” padding
Margin (top, right, bottom, left) Margin is the space outside the text/content and the border. You can use margin for all around the element or specify each side of the rectangle separately. The code could be any of the following: margin: 10px; or margin: 10px 10px; or margin: 10px 10px 10px 10px; or margin-left: 10px; margin-right: 10px; margin-bottom: 10px; margin-top: 10px; margin div id=“box”
Text Properties .mainHeading { color: red; letter-spacing: 5px; text-transform: uppercase; word-spacing: 15px; text-align: left; font-family: Times; text-decoration: underline; font-size: 12px; font-style: italic; font-weight: bold; } MAIN HEADING Gravida lacinia velit. Vivamus tortor enim, tincidunt at, pellentesque ut, iaculis eu, quam.  To style the main heading in the paragraph above, we assigned a class the HTML tag. <h3 class=“mainHeading”>Main Heading</h3>
CSS Colors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Standard Hexadecimal
Styling Links a:link {color: red; text-decoration: none;border-bottom: 1px dashed red; background: white;}  a:visited {color: yellow;} a:active {color: green;} a:hover {color: orange;} The links property defines how inactive, hovered, active, and visited  link  states appear to the user.
Including Images ,[object Object],[object Object],[object Object],[object Object],[object Object]
Layering Background colors and images are layered like sheets of paper one on top of the other.  #bg { background:url(leaves.jpg) no-repeat  top  left} #main {background-color: red} #box {background-color: yellow} div id=“bg” div id=“main” div id=“box”
Background-Image li { background-image:url(flower.jpg); padding-left: 10px; } Background images and colors are layered.  If not transparent, the last one listed in the CSS file is visible. The background-image property sets an image in the background of an element.
Background-Repeat li { background-image:url(flower.jpg);  background-repeat:no-repeat; } Possible Values  >  The background-repeat property sets an image in the background of an element and tiles, or repeats, it. Tiling is the default. ,[object Object],[object Object],[object Object],[object Object]
Image Positioning The background-position property positions the image using either combined keywords (top, bottom, left, right, and center); length values; or percentage values. The background-attachment property fixes or scrolls an image in the browser window. Values include  fixed  and  scroll . background-position: right top; /*can also use number values*/ background-attachment: fixed; /*can also use ‘scroll’*/  left  top center top left  bottom center bottom right bottom
The Power of Cascade ,[object Object],[object Object],[object Object],[object Object]
Saving Time with Inheritance In a nutshell,  inheritance  (not the money you get from your grandma) is the process by which CSS properties applied to one tag are passed on to nested tags. For example, the paragraph tag will inherit the same styling as the body tag because <p> is always located inside <body>. <body style=“font-family: Arial”> <p>This text will be Arial as well</p> </body> So, instead of styling each paragraph separately, you can define the font color in the <body>, and everything inside will have that color.
Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank You I hope you enjoyed this presentation and learned some basic CSS. Good luck with creating beautiful and functional Web sites.

More Related Content

What's hot

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Eye catching HTML BASICS tips: Learn easily
Eye catching HTML BASICS tips: Learn easilyEye catching HTML BASICS tips: Learn easily
Eye catching HTML BASICS tips: Learn easily
shabab shihan
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
Dave Kelly
 
Html ppt
Html pptHtml ppt
Html ppt
santosh lamba
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
HTML (Web) basics for a beginner
HTML (Web) basics for a beginnerHTML (Web) basics for a beginner
HTML (Web) basics for a beginner
Jayapal Reddy Nimmakayala
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
Webtech Learning
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
Harshita Yadav
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
Html presentation
Html presentationHtml presentation
Html presentation
Amber Bhaumik
 
CSS
CSSCSS
Css selectors
Css selectorsCss selectors
Css selectors
Parth Trivedi
 
Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
AakankshaR
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
Singsys Pte Ltd
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
www.netgains.org
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
fantasticdigitaltools
 
Html basics
Html basicsHtml basics
Html basics
mcatahir947
 
Html frames
Html framesHtml frames
Html frames
eShikshak
 

What's hot (20)

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Eye catching HTML BASICS tips: Learn easily
Eye catching HTML BASICS tips: Learn easilyEye catching HTML BASICS tips: Learn easily
Eye catching HTML BASICS tips: Learn easily
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
 
Html ppt
Html pptHtml ppt
Html ppt
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
HTML (Web) basics for a beginner
HTML (Web) basics for a beginnerHTML (Web) basics for a beginner
HTML (Web) basics for a beginner
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Html presentation
Html presentationHtml presentation
Html presentation
 
CSS
CSSCSS
CSS
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
Html basics
Html basicsHtml basics
Html basics
 
Html frames
Html framesHtml frames
Html frames
 

Similar to CSS Basics

CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
Shawn Calvert
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
Programmer Blog
 
CSS
CSSCSS
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for css
shabab shihan
 
Css introduction
Css  introductionCss  introduction
Css introduction
vishnu murthy
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Folasade Adedeji
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
Tom Hapgood
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
sanjay2211
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Senthil Kumar
 
David Weliver
David WeliverDavid Weliver
David Weliver
Philip Taylor
 
Html advance
Html advanceHtml advance
Html advance
PumoTechnovation
 
HTML-Advance.pptx
HTML-Advance.pptxHTML-Advance.pptx
HTML-Advance.pptx
Pandiya Rajan
 
Css ppt
Css pptCss ppt
Css ppt
Nidhi mishra
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
Knoldus Inc.
 

Similar to CSS Basics (20)

CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
 
CSS
CSSCSS
CSS
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
 
Make Css easy : easy tips for css
Make Css easy : easy tips for cssMake Css easy : easy tips for css
Make Css easy : easy tips for css
 
Css introduction
Css  introductionCss  introduction
Css introduction
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
Embrace the Mullet: CSS is the 'Party in the Back' (a CSS How-to)
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
David Weliver
David WeliverDavid Weliver
David Weliver
 
Html advance
Html advanceHtml advance
Html advance
 
HTML-Advance.pptx
HTML-Advance.pptxHTML-Advance.pptx
HTML-Advance.pptx
 
Css ppt
Css pptCss ppt
Css ppt
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 

Recently uploaded

Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State StoreElasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
ScyllaDB
 
Multivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back againMultivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back again
Kieran Kunhya
 
An All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS MarketAn All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS Market
ScyllaDB
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024
ThousandEyes
 
intra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_Enintra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_En
NTTDATA INTRAMART
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
Larry Smarr
 
Day 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data ManipulationDay 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data Manipulation
UiPathCommunity
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
ScyllaDB
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2
DianaGray10
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
Ortus Solutions, Corp
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc
 
APJC Introduction to ThousandEyes Webinar
APJC Introduction to ThousandEyes WebinarAPJC Introduction to ThousandEyes Webinar
APJC Introduction to ThousandEyes Webinar
ThousandEyes
 
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
anilsa9823
 
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
Chapter 5 - Managing Test Activities V4.0
Chapter 5 - Managing Test Activities V4.0Chapter 5 - Managing Test Activities V4.0
Chapter 5 - Managing Test Activities V4.0
Neeraj Kumar Singh
 
Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
ThousandEyes
 

Recently uploaded (20)

Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State StoreElasticity vs. State? Exploring Kafka Streams Cassandra State Store
Elasticity vs. State? Exploring Kafka Streams Cassandra State Store
 
Multivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back againMultivendor cloud production with VSF TR-11 - there and back again
Multivendor cloud production with VSF TR-11 - there and back again
 
An All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS MarketAn All-Around Benchmark of the DBaaS Market
An All-Around Benchmark of the DBaaS Market
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024New ThousandEyes Product Features and Release Highlights: June 2024
New ThousandEyes Product Features and Release Highlights: June 2024
 
intra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_Enintra-mart Accel series 2024 Spring updates_En
intra-mart Accel series 2024 Spring updates_En
 
From NCSA to the National Research Platform
From NCSA to the National Research PlatformFrom NCSA to the National Research Platform
From NCSA to the National Research Platform
 
Day 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data ManipulationDay 4 - Excel Automation and Data Manipulation
Day 4 - Excel Automation and Data Manipulation
 
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time MLMongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
MongoDB vs ScyllaDB: Tractian’s Experience with Real-Time ML
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2Communications Mining Series - Zero to Hero - Session 2
Communications Mining Series - Zero to Hero - Session 2
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
TrustArc Webinar - Your Guide for Smooth Cross-Border Data Transfers and Glob...
 
APJC Introduction to ThousandEyes Webinar
APJC Introduction to ThousandEyes WebinarAPJC Introduction to ThousandEyes Webinar
APJC Introduction to ThousandEyes Webinar
 
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
Call Girls Chennai ☎️ +91-7426014248 😍 Chennai Call Girl Beauty Girls Chennai...
 
ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024ThousandEyes New Product Features and Release Highlights: June 2024
ThousandEyes New Product Features and Release Highlights: June 2024
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
Chapter 5 - Managing Test Activities V4.0
Chapter 5 - Managing Test Activities V4.0Chapter 5 - Managing Test Activities V4.0
Chapter 5 - Managing Test Activities V4.0
 
Introduction to ThousandEyes AMER Webinar
Introduction  to ThousandEyes AMER WebinarIntroduction  to ThousandEyes AMER Webinar
Introduction to ThousandEyes AMER Webinar
 

CSS Basics

  • 1. The Basics of Cascading Style Sheets (CSS) Irina McGuire Graphic Designer | Front-End Web Developer www.irinamcguire.com December 3, 2010
  • 2.
  • 3.
  • 4. What is CSS? CSS stands for Cascading Style Sheet . Typical CSS file is a text file with an extention .css and contains a series of commands or rules. These rules tell the HTML how to display. *To create a style sheet, create a file using Notepad (PC) or Text Edit (Mac), save it as a .css document and start writing the CSS code (see right). /* Styles for sitename.com*/ body { font-family:Arial; background: #000; } #container { text-align:left; width:1020px; } #header { height:232px; } #footer { width: 100%; padding: 0 10px; margin-bottom: 10px; } And so on…. Style.css
  • 5.
  • 6. HTML Without CSS “ HTML without CSS is like a piece of candy without a pretty wrapper.” Without CSS, HTML elements typically flow from top to bottom of the page and position themselves to the left by default. With CSS help, we can create containers or DIVs to better organize content and make a Web page visually appealing.
  • 7.
  • 8. The Box Model CSS works on the box model. A typical Web page consists of many boxes joined together from top to bottom. These boxes can be stacked, nested, and can float. Header Navigation Content Footer
  • 9.
  • 10. CSS Rule Structure A CSS RULE is made up of a selector and a declaration. A declaration consists of property and value. selector { property: value; } declaration
  • 11. Selectors body { property : value ; } h1 { property : value ; } em { property : value ; } p { property : value ; } A selector, here in green , is often an element of HTML.
  • 12. Properties and Values body { background: purple; } h1 { color: green; } h2 { font-size: large; } p { color: #ff0000;} /*hexadecimal for red*/ body { background: purple; color: green; } Properties and values tell an HTML element how to display. *CSS code can be written in a linear format (above) or in a block format (below).
  • 13. Grouping Selectors h1 {color: black;} h1 {font-weight: bold;} h1 {background: white;} h1 { color: black; font-weight: bold; background: white; } Group the same selector with different declarations together on one line. Example of grouping selectors (both are correct):
  • 14. Grouping Selectors Group different selectors with the same declaration on one line. h1 { color: yellow; } h2 { color: yellow; } h3 { color: yellow; } h1, h2, h3 { color: yellow; } Example of grouping selectors (both are correct):
  • 15.
  • 16. Typical Web Page (Browser) header footer main menu Container
  • 17. Typical Web Page (HTML) <div id=“ container ”> <div id=“ header ”>Insert Title</div> <div id=“ main &quot;>content <div id=“ menu ”>content</div> </div> <div id=“ footer ”>content</div> </div> Typical HTML Web page is made up of containers (boxes) or DIVs. Each DIV is assigned an ID or a Class.
  • 18. Typical Web Page (CSS) # container {property: value;} # menu {property: value;} # main {property: value;} # footer {property: value;} The CSS file uses the same DIV/ID/Class names as the HTML and uses them to style the elements.
  • 19.
  • 20.
  • 21. HTML CSS div id=“header” div id=“footer” div id=“content” # content { background-color: #ccc; margin-bottom: 10px; border: 1px dashed blue; color: #fff; width: auto; }
  • 22.
  • 23. Width & Height div id=“box” #box {width=“50px”} #box {width=“50em”} #box {width=“100%”} #box {width=“auto”} Width and height define the width and height of an element. #box {height=“auto”} *Width and height can be specified in pixels, ems, percentages or set to auto
  • 24. Float: (left, right) Float property makes elements float to the right or left of the screen, positioned where they are in the HTML. Floating allows word wrapping. div id=“box” Here is some text which wraps around the box floated to the left. #box {float:left; margin-right: 10px;}
  • 25. Clear: (left, right, both) #box3 { background-color: white; border: 1px solid #000; clear: both;} When elements are floated, they wrap around each other to form a “caravan.” The clear property detaches an element from the “caravan” and allows it to start on a new line. div id=“box1” div id=“box2” div id=“box3”
  • 26. Border (top, right, bottom, left) #box { border-color: red; border-style: dotted; border-width: 2px; div id=“box” #box { border: red dotted 1px; #box { border-top: red dotted 1px; border-bottom: red dotted 1px; border-left: red dotted 1px; border-right: red dotted 1px; } You can define the entire border or only the top, bottom, left, or right. You can also define the border using one declaration. The code could be any of the following:
  • 27. Padding (top, right, bottom, left) Padding is the space between the text/content and the border. You can use padding for all around the element or specify each side of the rectangle separately. The code could be any of the following: padding: 10px; Padding: 10px 10px; padding: 10px 10px 10px 10px; padding-left: 10px; padding-right: 10px; padding-bottom: 10px; padding-top: 10px; div id=“box” padding
  • 28. Margin (top, right, bottom, left) Margin is the space outside the text/content and the border. You can use margin for all around the element or specify each side of the rectangle separately. The code could be any of the following: margin: 10px; or margin: 10px 10px; or margin: 10px 10px 10px 10px; or margin-left: 10px; margin-right: 10px; margin-bottom: 10px; margin-top: 10px; margin div id=“box”
  • 29. Text Properties .mainHeading { color: red; letter-spacing: 5px; text-transform: uppercase; word-spacing: 15px; text-align: left; font-family: Times; text-decoration: underline; font-size: 12px; font-style: italic; font-weight: bold; } MAIN HEADING Gravida lacinia velit. Vivamus tortor enim, tincidunt at, pellentesque ut, iaculis eu, quam. To style the main heading in the paragraph above, we assigned a class the HTML tag. <h3 class=“mainHeading”>Main Heading</h3>
  • 30.
  • 31. Styling Links a:link {color: red; text-decoration: none;border-bottom: 1px dashed red; background: white;} a:visited {color: yellow;} a:active {color: green;} a:hover {color: orange;} The links property defines how inactive, hovered, active, and visited link states appear to the user.
  • 32.
  • 33. Layering Background colors and images are layered like sheets of paper one on top of the other. #bg { background:url(leaves.jpg) no-repeat top left} #main {background-color: red} #box {background-color: yellow} div id=“bg” div id=“main” div id=“box”
  • 34. Background-Image li { background-image:url(flower.jpg); padding-left: 10px; } Background images and colors are layered. If not transparent, the last one listed in the CSS file is visible. The background-image property sets an image in the background of an element.
  • 35.
  • 36. Image Positioning The background-position property positions the image using either combined keywords (top, bottom, left, right, and center); length values; or percentage values. The background-attachment property fixes or scrolls an image in the browser window. Values include fixed and scroll . background-position: right top; /*can also use number values*/ background-attachment: fixed; /*can also use ‘scroll’*/ left top center top left bottom center bottom right bottom
  • 37.
  • 38. Saving Time with Inheritance In a nutshell, inheritance (not the money you get from your grandma) is the process by which CSS properties applied to one tag are passed on to nested tags. For example, the paragraph tag will inherit the same styling as the body tag because <p> is always located inside <body>. <body style=“font-family: Arial”> <p>This text will be Arial as well</p> </body> So, instead of styling each paragraph separately, you can define the font color in the <body>, and everything inside will have that color.
  • 39.
  • 40. Thank You I hope you enjoyed this presentation and learned some basic CSS. Good luck with creating beautiful and functional Web sites.

Editor's Notes

  1. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  2. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  3. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  4. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  5. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  6. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  7. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  8. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  9. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  10. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  11. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  12. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  13. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  14. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  15. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  16. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  17. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  18. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  19. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  20. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  21. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  22. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  23. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  24. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  25. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  26. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  27. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  28. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  29. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  30. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  31. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  32. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  33. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  34. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  35. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  36. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  37. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  38. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  39. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  40. Cascading Style Sheets: Pixel-Level Control with HTML Ease
  翻译: