SlideShare une entreprise Scribd logo
1  sur  26
WEEK 6 
WEEK 11: 
CSS (CASCADING 
STYLE SHEETS)
GOALS FOR TODAY 
• Review what CSS is 
• Writing CSS Targeting Selectors 
• Types of Selectors 
• CSS Cascade (Order) 
• Applying basic CSS properties
HTML IS THE FOUNDATION, 
CSS IS THE PRESENTATION
REVIEW: 
WHAT IS CSS? 
• CSS (Cascading Style Sheets) is a style sheet language developed to 
control the presentation (look and feel) of markup language documents, in 
our case HTML 
• CSS is a collection of formatting rules 
Examples: 
• size of font 
• color of font 
• font family 
• margins, 
• border, 
• underline etc…
WHAT IS CSS? 
<< WITHOUT CSS 
<< WITH CSS
SPECIFY AND TARGET STYLES 
There are 3 main ways to specify and target styles in our web pages
APPLYING CSS 
ANATOMY 
OF A CSS 
STYLE
ANATOMY OF A CSS STYLE
ANATOMY OF A CSS STYLE 
p { 
color: red; 
font-size: 13px; 
font-family: arial; 
font-weight: bold; 
} 
You can write CSS 
either way, they do 
the same thing 
p { color: red; font-size: 13px; font-family: arial; font-weight: bold;} 
Result: 
<p> Just some text for demonstration purposes. </p>
ELEMENT SELECTORS: 
FOR REGULAR HTML TAGS 
• The element selector selects all elements (tags) with the specified 
element name 
• These are very broad and the styles given to them would apply to all 
• Elements selectors refer to regular HTML tags 
p { color: red; } 
h1 { color: yellow; } 
ul { color: red; } 
strong { color: blue; } 
em { color: green; }
ELEMENT SELECTORS: 
FOR REGULAR HTML TAGS
CLASS SELECTORS: 
FOR ANY ELEMENT 
• Classes are html attributes that can be added to any html 
element (<p>, <h1>, <strong>, <em>, etc.) 
• Classes can be named anything 
• You can apply a class as many times on a page as needed 
• Class selectors always start with a period in the css file (.ex) 
CSS: 
.subhead { color: red; } 
HTML: 
<h2 class=”subhead”>My Subhead</h2>
CLASS SELECTORS: 
FOR ANY ELEMENT
ID SELECTORS: 
FOR ANY ONE ELEMENT ON A PAGE 
• The id selector uses the id attribute of an HTML tag to find the 
specific element. 
• An id should be unique within a page, so you should use the 
id selector when you want to find a single, unique element. 
CSS: 
#subhead { color: red; } 
HTML: 
<h2 id=”subhead”>My Subhead</h2>
CSS CASCADE (ORDER) 
From general to specific
THE CASCADE (ORDER) 
(VERY IMPORTANT!) 
• CSS cascade is very 
important, whether you 
want to style a very 
specific element on a 
page or a HTML elements 
in a general tag 
• With no CSS on a page, 
the browser’s default 
styles will be used 
• CSS is just like HTML, it is 
read top to bottom, left to 
right
WEB COLOUR 
RGB vs HEX, web safe vs millions…
WEB COLOUR 
In the Stone Age… 
In the stone age, when computers 
only supported 256 different colors, 
a list of 216 "Web Safe Colors" was 
suggested as a Web standard, 
reserving 40 fixed system colors. 
This 216 cross-browser color 
palette was created to ensure that 
all computers would display colors 
correctly:
WEB COLOURS 
Colors are displayed combining 
RED, GREEN, and BLUE light. 
The combination of Red, Green 
and Blue values from 0 to 255 
gives a total of more than 16 
million different colors to play 
with (256 x 256 x 256). 
Most modern monitors are 
capable of displaying at least 
16384 different colors.
COLOUR VALUES 
Colors are defined using a hexadecimal (hex) notation for the 
of Red, Green, and Blue values (RGB). 
• The lowest value for each light source is 0 (hex 00) 
• The highest value is 255 (hex FF) 
• Hex values are written as # followed by either three or six hex 
characters, eg: #990033 
Try it! 
• See the web links in Week 10
APPLYING STYLES TO A PAGE OR SITE
3 WAYS TO APPLY STYLES 
1 - Embedded style: 
• Typed directly into each html document, applies only to that 
document, embedded in the <head></head> section 
2 - Linked style sheet 
• Separate style sheet written and then linked to each document 
• This allows you to control the style of an entire site consisting of 
more then 1 page from 1 style sheet 
• Links to style sheets go in the <head></head> section 
3 – In-line 
• An inline style loses many of the advantages of a style sheet (by 
mixing content with presentation). Use this method sparingly! 
• To use inline styles, add the style attribute to the relevant tag
EMBEDDING CSS 
• To embedded CSS styles in your 
document the <style> tags are added 
inside of the <head></head> tags at 
the top of your document. 
• Your custom CSS styles (or rules) are 
placed inside of the <style></style> 
tags 
Embedding css directly on a 
page limits it to JUST that 
page 
• This has pros can cons: Pro: maybe 
you just need it applied to that page, 
con: doing this on multiple pages 
would be a lot of work!
LINKING CSS STYLE SHEETS 
• Linking a style sheet means that you can control the 
presentation of a site consisting of multiple pages from 1 CSS 
file 
You link to a separate file: 
• <link href="global.css" rel="stylesheet" type="text/css" /> 
• Linked Style Sheet are named with a .css extention (ie. 
global.css). 
• Linked Style Sheet are added in head section between the 
opening and closing head tags just like embedded CSS styles 
This is the technique we will be using in class
LINKED STYLE SHEETS CAN BE 
APPLIED TO MULTIPLE PAGES 
This makes updating much easier!
BASIC CSS PROPERTIES 
p {color: olive;} 
• “p” is the selector, “color” is the 
property and “olive” is the value 
color: blue; 
• modifies the color property of your 
chosen font, default is black 
• you use keywords (red) or 
hexadecimal (#e0e0e0) 
font-size: 13px; 
• modifies the size property of your 
chosen font 
• Can be measured in px, em, or pts 
font-weight: normal; 
font-weight: bold; 
• controls the weight of the font, either 
bold or normal 
background-color: yellow; 
• sets the background property of an 
element, can you use keywords (red) or 
hexadecimal (#e0e0e0) 
Important! With CSS it is 
always property first, 
value second

Contenu connexe

Tendances

Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)Harshil Darji
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introductionapnwebdev
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSSAmit Tyagi
 
Responsive web design with html5 and css3
Responsive web design with html5 and css3Responsive web design with html5 and css3
Responsive web design with html5 and css3Divya Tiwari
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxpriyadharshini murugan
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation Salman Memon
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)Harshita Yadav
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSSispkosova
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1Jyoti Yadav
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Likitha47
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And TipsCSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And TipsReema
 
Cascading style sheet (css)]
Cascading style sheet (css)]Cascading style sheet (css)]
Cascading style sheet (css)]9574395990
 

Tendances (20)

Introducing Cascading Style Sheets
Introducing Cascading Style SheetsIntroducing Cascading Style Sheets
Introducing Cascading Style Sheets
 
Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
CSS 101
CSS 101CSS 101
CSS 101
 
Responsive web design with html5 and css3
Responsive web design with html5 and css3Responsive web design with html5 and css3
Responsive web design with html5 and css3
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntax
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSS
 
4. Web Technology CSS Basics-1
4. Web Technology CSS Basics-14. Web Technology CSS Basics-1
4. Web Technology CSS Basics-1
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Css
CssCss
Css
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And TipsCSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And Tips
 
Cascading style sheet (css)]
Cascading style sheet (css)]Cascading style sheet (css)]
Cascading style sheet (css)]
 
Css introduction
Css   introductionCss   introduction
Css introduction
 
Css present
Css presentCss present
Css present
 
Html
HtmlHtml
Html
 
Css
CssCss
Css
 

En vedette (9)

Week 4 - tablet app design
Week 4 - tablet app designWeek 4 - tablet app design
Week 4 - tablet app design
 
Interactive Web Design 5 - Week 2 - Introduction
Interactive Web Design 5 - Week 2 -  IntroductionInteractive Web Design 5 - Week 2 -  Introduction
Interactive Web Design 5 - Week 2 - Introduction
 
Week 3 Lecture: Accessibility
Week 3 Lecture: AccessibilityWeek 3 Lecture: Accessibility
Week 3 Lecture: Accessibility
 
Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)
Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)
Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)
 
Week 12 CSS Font - size
Week 12 CSS Font - sizeWeek 12 CSS Font - size
Week 12 CSS Font - size
 
Module 3 - Intro to Bootstrap
Module 3 - Intro to BootstrapModule 3 - Intro to Bootstrap
Module 3 - Intro to Bootstrap
 
Module 5 - WCM system comparison
Module 5 - WCM system comparison Module 5 - WCM system comparison
Module 5 - WCM system comparison
 
HTML Lecture Part 1 of 2
HTML Lecture Part 1 of 2HTML Lecture Part 1 of 2
HTML Lecture Part 1 of 2
 
HTML/CSS Lecture 1
HTML/CSS Lecture 1HTML/CSS Lecture 1
HTML/CSS Lecture 1
 

Similaire à Week11 Lecture: CSS

Similaire à Week11 Lecture: CSS (20)

Css
CssCss
Css
 
Cascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptxCascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptx
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptx
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
BITM3730 9-20.pptx
BITM3730 9-20.pptxBITM3730 9-20.pptx
BITM3730 9-20.pptx
 
2 introduction css
2 introduction css2 introduction css
2 introduction css
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptxWEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
 
Css
CssCss
Css
 
CSS.pptx
CSS.pptxCSS.pptx
CSS.pptx
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdf
 
CSS
CSSCSS
CSS
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
DHTML
DHTMLDHTML
DHTML
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
Css
CssCss
Css
 
Css basics
Css basicsCss basics
Css basics
 
Unit 3 (it workshop).pptx
Unit 3 (it workshop).pptxUnit 3 (it workshop).pptx
Unit 3 (it workshop).pptx
 
Css
CssCss
Css
 
Internet tech &amp; web prog. p4,5
Internet tech &amp; web prog.  p4,5Internet tech &amp; web prog.  p4,5
Internet tech &amp; web prog. p4,5
 

Plus de Katherine McCurdy-Lapierre, R.G.D. (11)

Week 12 CSS Font - family
Week 12 CSS Font - familyWeek 12 CSS Font - family
Week 12 CSS Font - family
 
Week 6 Lecture
Week 6 LectureWeek 6 Lecture
Week 6 Lecture
 
Week 5 Lecture
Week 5 LectureWeek 5 Lecture
Week 5 Lecture
 
Week 4 Lecture Accessibility
Week 4 Lecture AccessibilityWeek 4 Lecture Accessibility
Week 4 Lecture Accessibility
 
Week 4 Lecture Part 1
Week 4 Lecture Part 1Week 4 Lecture Part 1
Week 4 Lecture Part 1
 
Week 4 Lecture Part 2
Week 4 Lecture Part 2Week 4 Lecture Part 2
Week 4 Lecture Part 2
 
Artistic Web Applications - Week3 - Part 1
Artistic Web Applications - Week3 - Part 1Artistic Web Applications - Week3 - Part 1
Artistic Web Applications - Week3 - Part 1
 
Artistic Web Applications - Week3 - Part 3
Artistic Web Applications - Week3 - Part 3Artistic Web Applications - Week3 - Part 3
Artistic Web Applications - Week3 - Part 3
 
Artistic Web Applications - Week3 - Part 2
Artistic Web Applications - Week3 - Part 2Artistic Web Applications - Week3 - Part 2
Artistic Web Applications - Week3 - Part 2
 
Week2 lecture-whatiswebdesign-part1
Week2 lecture-whatiswebdesign-part1Week2 lecture-whatiswebdesign-part1
Week2 lecture-whatiswebdesign-part1
 
LecWeek2 lecture-whatiswebdesign-part2
LecWeek2 lecture-whatiswebdesign-part2LecWeek2 lecture-whatiswebdesign-part2
LecWeek2 lecture-whatiswebdesign-part2
 

Dernier

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Dernier (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

Week11 Lecture: CSS

  • 1. WEEK 6 WEEK 11: CSS (CASCADING STYLE SHEETS)
  • 2. GOALS FOR TODAY • Review what CSS is • Writing CSS Targeting Selectors • Types of Selectors • CSS Cascade (Order) • Applying basic CSS properties
  • 3. HTML IS THE FOUNDATION, CSS IS THE PRESENTATION
  • 4. REVIEW: WHAT IS CSS? • CSS (Cascading Style Sheets) is a style sheet language developed to control the presentation (look and feel) of markup language documents, in our case HTML • CSS is a collection of formatting rules Examples: • size of font • color of font • font family • margins, • border, • underline etc…
  • 5. WHAT IS CSS? << WITHOUT CSS << WITH CSS
  • 6. SPECIFY AND TARGET STYLES There are 3 main ways to specify and target styles in our web pages
  • 7. APPLYING CSS ANATOMY OF A CSS STYLE
  • 8. ANATOMY OF A CSS STYLE
  • 9. ANATOMY OF A CSS STYLE p { color: red; font-size: 13px; font-family: arial; font-weight: bold; } You can write CSS either way, they do the same thing p { color: red; font-size: 13px; font-family: arial; font-weight: bold;} Result: <p> Just some text for demonstration purposes. </p>
  • 10. ELEMENT SELECTORS: FOR REGULAR HTML TAGS • The element selector selects all elements (tags) with the specified element name • These are very broad and the styles given to them would apply to all • Elements selectors refer to regular HTML tags p { color: red; } h1 { color: yellow; } ul { color: red; } strong { color: blue; } em { color: green; }
  • 11. ELEMENT SELECTORS: FOR REGULAR HTML TAGS
  • 12. CLASS SELECTORS: FOR ANY ELEMENT • Classes are html attributes that can be added to any html element (<p>, <h1>, <strong>, <em>, etc.) • Classes can be named anything • You can apply a class as many times on a page as needed • Class selectors always start with a period in the css file (.ex) CSS: .subhead { color: red; } HTML: <h2 class=”subhead”>My Subhead</h2>
  • 13. CLASS SELECTORS: FOR ANY ELEMENT
  • 14. ID SELECTORS: FOR ANY ONE ELEMENT ON A PAGE • The id selector uses the id attribute of an HTML tag to find the specific element. • An id should be unique within a page, so you should use the id selector when you want to find a single, unique element. CSS: #subhead { color: red; } HTML: <h2 id=”subhead”>My Subhead</h2>
  • 15. CSS CASCADE (ORDER) From general to specific
  • 16. THE CASCADE (ORDER) (VERY IMPORTANT!) • CSS cascade is very important, whether you want to style a very specific element on a page or a HTML elements in a general tag • With no CSS on a page, the browser’s default styles will be used • CSS is just like HTML, it is read top to bottom, left to right
  • 17. WEB COLOUR RGB vs HEX, web safe vs millions…
  • 18. WEB COLOUR In the Stone Age… In the stone age, when computers only supported 256 different colors, a list of 216 "Web Safe Colors" was suggested as a Web standard, reserving 40 fixed system colors. This 216 cross-browser color palette was created to ensure that all computers would display colors correctly:
  • 19. WEB COLOURS Colors are displayed combining RED, GREEN, and BLUE light. The combination of Red, Green and Blue values from 0 to 255 gives a total of more than 16 million different colors to play with (256 x 256 x 256). Most modern monitors are capable of displaying at least 16384 different colors.
  • 20. COLOUR VALUES Colors are defined using a hexadecimal (hex) notation for the of Red, Green, and Blue values (RGB). • The lowest value for each light source is 0 (hex 00) • The highest value is 255 (hex FF) • Hex values are written as # followed by either three or six hex characters, eg: #990033 Try it! • See the web links in Week 10
  • 21. APPLYING STYLES TO A PAGE OR SITE
  • 22. 3 WAYS TO APPLY STYLES 1 - Embedded style: • Typed directly into each html document, applies only to that document, embedded in the <head></head> section 2 - Linked style sheet • Separate style sheet written and then linked to each document • This allows you to control the style of an entire site consisting of more then 1 page from 1 style sheet • Links to style sheets go in the <head></head> section 3 – In-line • An inline style loses many of the advantages of a style sheet (by mixing content with presentation). Use this method sparingly! • To use inline styles, add the style attribute to the relevant tag
  • 23. EMBEDDING CSS • To embedded CSS styles in your document the <style> tags are added inside of the <head></head> tags at the top of your document. • Your custom CSS styles (or rules) are placed inside of the <style></style> tags Embedding css directly on a page limits it to JUST that page • This has pros can cons: Pro: maybe you just need it applied to that page, con: doing this on multiple pages would be a lot of work!
  • 24. LINKING CSS STYLE SHEETS • Linking a style sheet means that you can control the presentation of a site consisting of multiple pages from 1 CSS file You link to a separate file: • <link href="global.css" rel="stylesheet" type="text/css" /> • Linked Style Sheet are named with a .css extention (ie. global.css). • Linked Style Sheet are added in head section between the opening and closing head tags just like embedded CSS styles This is the technique we will be using in class
  • 25. LINKED STYLE SHEETS CAN BE APPLIED TO MULTIPLE PAGES This makes updating much easier!
  • 26. BASIC CSS PROPERTIES p {color: olive;} • “p” is the selector, “color” is the property and “olive” is the value color: blue; • modifies the color property of your chosen font, default is black • you use keywords (red) or hexadecimal (#e0e0e0) font-size: 13px; • modifies the size property of your chosen font • Can be measured in px, em, or pts font-weight: normal; font-weight: bold; • controls the weight of the font, either bold or normal background-color: yellow; • sets the background property of an element, can you use keywords (red) or hexadecimal (#e0e0e0) Important! With CSS it is always property first, value second