SlideShare a Scribd company logo
Web Programming
SYED SHAHZAIB SOHAIL
Lecture 5
Introduction to CSS
Contents
• What is CSS?
• Why use CSS?
• Ways to use CSS
• Big Problem
• CSS Syntax
• CSS Selectors and its types
• Grouping Selectors
• CSS Comments
What is CSS?
• CSS stands for Cascading Style Sheets
• CSS defines the presentation ofWeb Pages
• CSS describes how HTML elements are to be displayed on screen, paper or
in other media
• CSS saves a lot of work. It can control the layout of multiple web pages at
once
Why use CSS?
• CSS is used to defines styles of your web pages, including the design, layout
and variations in display for different devices and screen sizes.
Ways to use CSS
• CSS can be used in 3 different ways.
• Inline CSS
• Internal CSS
• External CSS
Continued…
• Inline CSS
• Inline CSS allows you to apply a unique style to one HTML element at a time.
• You assign CSS to a specific HTML tag by using style attribute with any CSS properties
defined within it.
• Inline CSS style will always override style properties determined in internal or external
files.
<p style=“color: blue;”>This is a paragraph</p>
This is a paragraph
Continued…
• Internal CSS
• The internal style sheet is used to add a unique style for a single document.
• It is defined in <head> section of the HTML page inside the <style> tag.
Continued…
• External CSS
• The external style sheet is generally used when you want to make changes on multiple pages.
• It is ideal for this condition because it facilitates you to change the look of the entire website by
changing just one file.
• It used the <link> tag on every pages and the <link> tag should be put inside the head section.
<head>
<link rel=“stylesheet” type=“text/css” href=“style.css”>
</head>
• The external style sheet may be written in text editor but must be saved with a .css extension.This
file should not contain HTML elements
•What style will be used when there is more than one
style specified for an HTML element?
Continued…
• If there are multiple style sheets the priority level is defined as following:
1. Inline style sheet
2. Internal style sheet
3. External style sheet
Big Problem
• HTML was never intended to contain tags for formatting a web page
• HTML was created to describe the content of the web page
• When tags like <font> and color attributes were added to the HTML 3.2
specification, it started a nightmare for web developers. Development of large
websites, where fonts and color information were added to every single page,
became a long and expensive process
• To solve this problem, theWorld Wide Web Consortium (W3C) created CSS that
removed the style formatting from the HTML page
CSS Syntax
• A CSS rule-set consists of a selector and a declaration block:
H1 {color:blue; font-size:12px;}
Selector Declaration Declaration
Property Value Property Value
Continued...
• The selector points to the HTML element you want to style
• The declaration block contains one or more declarations separated by
semicolons
• Each declaration includes a CSS property name and a value, separated by
semicolon
• A CSS declaration always ends with a semicolon and declaration blocks are
surrounded by curly braces
CSS Selectors
• CSS selectors are used to “find” (or select) HTML elements based on their
element name, id, class, attribute and more
Types of CSS Selectors
• There are 3 types of CSS selectors
• Element Selector
• Id Selector
• Class Selector
• Child Selector
• Attribute Selector
Continued…
• Element Selector
• The element selector selects elements based on the element name.
• Id Selector
• The id selector used the id attribute of an HTML element to select a specific element.
• The id of an element should be unique within a page, so the id selector is used to select
one unique element.
• To select an element with a specific id, write a hash character, followed by the id of the
element.
Continued…
• Class Selector
• The class selector selects elements with a specific class attribute.
• To select elements with a specific class, write a period character, followed by the name of
the class.
.center {text-align: center; color: red;}
• You can also specify that only specific HTML elements should be affected by a class.
p. center {text-align: center; color: red;}
• HTML elements can also refer to more than one class.
<p class=“center large”>This paragraph refers to two classes</p>
Continued…
• Child Selector
body > p {color: #000000;}
• Attribute Selector
• You can also apply styles to HTML elements with particular attributes
• input[type=“text”] {color: #000000;}
Grouping Selectors
• If you have elements with the same style definitions, like
• h1 {text-align: center; color: red;}
• h2 {text-align: center; color: red;}
• p {text-align: center; color: red;}
• It will be better to group the selectors, to minimize the code.
• To group selectors, separate each selector with a comma.
• h1, h2, p {text-align: center; color: red;}
CSS Comments
• Comments are used to explain the code, and may help when you edit the
source code at a later date
• Comments are ignored by browsers
• A CSS comment starts with /* and ends with */
• Single Line and Multiline Comments
Ad

Recommended

Web Development - Lecture 3
Web Development - Lecture 3
Syed Shahzaib Sohail
 
Web Development - Lecture 4
Web Development - Lecture 4
Syed Shahzaib Sohail
 
Web Development - Lecture 2
Web Development - Lecture 2
Syed Shahzaib Sohail
 
Web Development - Lecture 6
Web Development - Lecture 6
Syed Shahzaib Sohail
 
Css
Css
Army Public School and College -Faisal
 
CSS
CSS
venkatachalam84
 
CSS Basics (Cascading Style Sheet)
CSS Basics (Cascading Style Sheet)
Ajay Khatri
 
Introduction to CSS
Introduction to CSS
Folasade Adedeji
 
Html
Html
Kamal Acharya
 
Introduction to CSS
Introduction to CSS
Amit Tyagi
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Responsive web design with html5 and css3
Responsive web design with html5 and css3
Divya Tiwari
 
Html and css
Html and css
Sukrit Gupta
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)
Webtech Learning
 
chitra
chitra
sweet chitra
 
What is CSS?
What is CSS?
HalaiHansaika
 
Ia css
Ia css
osman do
 
CSS (Cascading Style Sheet)
CSS (Cascading Style Sheet)
Harshit Srivastava
 
Css
Css
Kamal Acharya
 
CSS
CSS
seedinteractive
 
CSS 101
CSS 101
dunclair
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSS
Sun Technlogies
 
Web Development 3 (HTML & CSS)
Web Development 3 (HTML & CSS)
ghayour abbas
 
Cascading style sheets
Cascading style sheets
smitha273566
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And Tips
Reema
 
Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)
ghayour abbas
 
Cascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptx
alvindalejoyosa1
 
cascading style sheets- About cascading style sheets on the selectors
cascading style sheets- About cascading style sheets on the selectors
JayanthiM19
 

More Related Content

What's hot (20)

Html
Html
Kamal Acharya
 
Introduction to CSS
Introduction to CSS
Amit Tyagi
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Responsive web design with html5 and css3
Responsive web design with html5 and css3
Divya Tiwari
 
Html and css
Html and css
Sukrit Gupta
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)
Webtech Learning
 
chitra
chitra
sweet chitra
 
What is CSS?
What is CSS?
HalaiHansaika
 
Ia css
Ia css
osman do
 
CSS (Cascading Style Sheet)
CSS (Cascading Style Sheet)
Harshit Srivastava
 
Css
Css
Kamal Acharya
 
CSS
CSS
seedinteractive
 
CSS 101
CSS 101
dunclair
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSS
Sun Technlogies
 
Web Development 3 (HTML & CSS)
Web Development 3 (HTML & CSS)
ghayour abbas
 
Cascading style sheets
Cascading style sheets
smitha273566
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And Tips
Reema
 
Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)
ghayour abbas
 
Introduction to CSS
Introduction to CSS
Amit Tyagi
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Responsive web design with html5 and css3
Responsive web design with html5 and css3
Divya Tiwari
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)
Webtech Learning
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation
Salman Memon
 
Cascading Style Sheets - CSS
Cascading Style Sheets - CSS
Sun Technlogies
 
Web Development 3 (HTML & CSS)
Web Development 3 (HTML & CSS)
ghayour abbas
 
Cascading style sheets
Cascading style sheets
smitha273566
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And Tips
Reema
 
Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)
ghayour abbas
 

Similar to Web Development - Lecture 5 (20)

Cascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptx
alvindalejoyosa1
 
cascading style sheets- About cascading style sheets on the selectors
cascading style sheets- About cascading style sheets on the selectors
JayanthiM19
 
Lecture-6.pptx
Lecture-6.pptx
vishal choudhary
 
Unit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.ppt
TusharTikia
 
Ifi7174 lesson2
Ifi7174 lesson2
Sónia
 
3. CSS
3. CSS
Pavle Đorđević
 
Learning CSS for beginners.ppt all that are but
Learning CSS for beginners.ppt all that are but
DangyiGodSees
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
CSS Training in Bangalore
CSS Training in Bangalore
rajkamal560066
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Erin M. Kidwell
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptx
GmachImen
 
Lecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType Classification
ZahouAmel1
 
Introduction to CSS
Introduction to CSS
Shehzad Yaqoob
 
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session5
Building Next Generation Websites Session5
Muhammad Ehtisham Siddiqui
 
Introduction to CSS.pptx web for web web
Introduction to CSS.pptx web for web web
compengwaelalahmar
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
karthiksmart21
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
Introduction to css
Introduction to css
Joseph Gabriel
 
LIS3353 SP12 Week 13
LIS3353 SP12 Week 13
Amanda Case
 
Cascading Style Sheets for web browser.pptx
Cascading Style Sheets for web browser.pptx
alvindalejoyosa1
 
cascading style sheets- About cascading style sheets on the selectors
cascading style sheets- About cascading style sheets on the selectors
JayanthiM19
 
Unit 2-CSS & Bootstrap.ppt
Unit 2-CSS & Bootstrap.ppt
TusharTikia
 
Ifi7174 lesson2
Ifi7174 lesson2
Sónia
 
Learning CSS for beginners.ppt all that are but
Learning CSS for beginners.ppt all that are but
DangyiGodSees
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
CSS Training in Bangalore
CSS Training in Bangalore
rajkamal560066
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Erin M. Kidwell
 
Lecture 3CSS part 1.pptx
Lecture 3CSS part 1.pptx
GmachImen
 
Lecture 9 CSS part 1.pptxType Classification
Lecture 9 CSS part 1.pptxType Classification
ZahouAmel1
 
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Introduction to CSS.pptx web for web web
Introduction to CSS.pptx web for web web
compengwaelalahmar
 
WEB TECHNOLOGY Unit-2.pptx
WEB TECHNOLOGY Unit-2.pptx
karthiksmart21
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
LIS3353 SP12 Week 13
LIS3353 SP12 Week 13
Amanda Case
 
Ad

Recently uploaded (20)

LRC image social media marketing class design
LRC image social media marketing class design
yeshwimbu
 
Development of a Reinforcement Learning-Based Optimization Model for Customer...
Development of a Reinforcement Learning-Based Optimization Model for Customer...
ljo758
 
week2.pptx program program program problems
week2.pptx program program program problems
doramira833
 
The power of storytelling in design.pdf
The power of storytelling in design.pdf
Zohaib421
 
roadsafety_training_manual_unit_1_magnitude_and_impact.ppt
roadsafety_training_manual_unit_1_magnitude_and_impact.ppt
mbkl05cctjv
 
overview visual graphic design for SHS.pptx
overview visual graphic design for SHS.pptx
KarlVincentNonog
 
Clamp_and_bend_device_exercisee_SFC.pptx
Clamp_and_bend_device_exercisee_SFC.pptx
DhanushJCS1
 
animewitcher.cc https://animewitcher.cc/
animewitcher.cc https://animewitcher.cc/
Anime witcher
 
Presentation.pptx tinkercadjajsjhdhdhdhs
Presentation.pptx tinkercadjajsjhdhdhdhs
sukh27012
 
Transformative Storytelling_ Insights from the Sankofa Writing Intensive.pdf
Transformative Storytelling_ Insights from the Sankofa Writing Intensive.pdf
Dr. Rema
 
Modern Living Room Design in Tokyo,Japan
Modern Living Room Design in Tokyo,Japan
Yantram Animation Studio Corporation
 
最新版意大利布雷西亚自由美术学院毕业证(LABA毕业证书)原版定制
最新版意大利布雷西亚自由美术学院毕业证(LABA毕业证书)原版定制
taqyea
 
The-Future-of-Fashion-in-Singapore-Moushumi-Khara.pdf
The-Future-of-Fashion-in-Singapore-Moushumi-Khara.pdf
The Lifestyle Editor
 
The Gardens Between - A moment breakdown
The Gardens Between - A moment breakdown
ScorpGrd
 
Bethany Michels Architecture Portfolio.pdf
Bethany Michels Architecture Portfolio.pdf
Bethany Michels
 
research proposal on IDA By dr waleed zaheen.pptx
research proposal on IDA By dr waleed zaheen.pptx
waleedzaheen1
 
Bahan kuliah tambahan perpandsebagai pengganti liburan.ppt
Bahan kuliah tambahan perpandsebagai pengganti liburan.ppt
Kristyadi Daripada Paidi
 
Quectel M10 AT commands Arduino Microcontroller
Quectel M10 AT commands Arduino Microcontroller
AdamSunusiHaruna1
 
week3.pptx python related programs and outputs
week3.pptx python related programs and outputs
doramira833
 
Genting Kecamatan Samadua Tahun 2025.pptx
Genting Kecamatan Samadua Tahun 2025.pptx
fazrulichsanmilan
 
LRC image social media marketing class design
LRC image social media marketing class design
yeshwimbu
 
Development of a Reinforcement Learning-Based Optimization Model for Customer...
Development of a Reinforcement Learning-Based Optimization Model for Customer...
ljo758
 
week2.pptx program program program problems
week2.pptx program program program problems
doramira833
 
The power of storytelling in design.pdf
The power of storytelling in design.pdf
Zohaib421
 
roadsafety_training_manual_unit_1_magnitude_and_impact.ppt
roadsafety_training_manual_unit_1_magnitude_and_impact.ppt
mbkl05cctjv
 
overview visual graphic design for SHS.pptx
overview visual graphic design for SHS.pptx
KarlVincentNonog
 
Clamp_and_bend_device_exercisee_SFC.pptx
Clamp_and_bend_device_exercisee_SFC.pptx
DhanushJCS1
 
animewitcher.cc https://animewitcher.cc/
animewitcher.cc https://animewitcher.cc/
Anime witcher
 
Presentation.pptx tinkercadjajsjhdhdhdhs
Presentation.pptx tinkercadjajsjhdhdhdhs
sukh27012
 
Transformative Storytelling_ Insights from the Sankofa Writing Intensive.pdf
Transformative Storytelling_ Insights from the Sankofa Writing Intensive.pdf
Dr. Rema
 
最新版意大利布雷西亚自由美术学院毕业证(LABA毕业证书)原版定制
最新版意大利布雷西亚自由美术学院毕业证(LABA毕业证书)原版定制
taqyea
 
The-Future-of-Fashion-in-Singapore-Moushumi-Khara.pdf
The-Future-of-Fashion-in-Singapore-Moushumi-Khara.pdf
The Lifestyle Editor
 
The Gardens Between - A moment breakdown
The Gardens Between - A moment breakdown
ScorpGrd
 
Bethany Michels Architecture Portfolio.pdf
Bethany Michels Architecture Portfolio.pdf
Bethany Michels
 
research proposal on IDA By dr waleed zaheen.pptx
research proposal on IDA By dr waleed zaheen.pptx
waleedzaheen1
 
Bahan kuliah tambahan perpandsebagai pengganti liburan.ppt
Bahan kuliah tambahan perpandsebagai pengganti liburan.ppt
Kristyadi Daripada Paidi
 
Quectel M10 AT commands Arduino Microcontroller
Quectel M10 AT commands Arduino Microcontroller
AdamSunusiHaruna1
 
week3.pptx python related programs and outputs
week3.pptx python related programs and outputs
doramira833
 
Genting Kecamatan Samadua Tahun 2025.pptx
Genting Kecamatan Samadua Tahun 2025.pptx
fazrulichsanmilan
 
Ad

Web Development - Lecture 5

  • 3. Contents • What is CSS? • Why use CSS? • Ways to use CSS • Big Problem • CSS Syntax • CSS Selectors and its types • Grouping Selectors • CSS Comments
  • 4. What is CSS? • CSS stands for Cascading Style Sheets • CSS defines the presentation ofWeb Pages • CSS describes how HTML elements are to be displayed on screen, paper or in other media • CSS saves a lot of work. It can control the layout of multiple web pages at once
  • 5. Why use CSS? • CSS is used to defines styles of your web pages, including the design, layout and variations in display for different devices and screen sizes.
  • 6. Ways to use CSS • CSS can be used in 3 different ways. • Inline CSS • Internal CSS • External CSS
  • 7. Continued… • Inline CSS • Inline CSS allows you to apply a unique style to one HTML element at a time. • You assign CSS to a specific HTML tag by using style attribute with any CSS properties defined within it. • Inline CSS style will always override style properties determined in internal or external files. <p style=“color: blue;”>This is a paragraph</p> This is a paragraph
  • 8. Continued… • Internal CSS • The internal style sheet is used to add a unique style for a single document. • It is defined in <head> section of the HTML page inside the <style> tag.
  • 9. Continued… • External CSS • The external style sheet is generally used when you want to make changes on multiple pages. • It is ideal for this condition because it facilitates you to change the look of the entire website by changing just one file. • It used the <link> tag on every pages and the <link> tag should be put inside the head section. <head> <link rel=“stylesheet” type=“text/css” href=“style.css”> </head> • The external style sheet may be written in text editor but must be saved with a .css extension.This file should not contain HTML elements
  • 10. •What style will be used when there is more than one style specified for an HTML element?
  • 11. Continued… • If there are multiple style sheets the priority level is defined as following: 1. Inline style sheet 2. Internal style sheet 3. External style sheet
  • 12. Big Problem • HTML was never intended to contain tags for formatting a web page • HTML was created to describe the content of the web page • When tags like <font> and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. Development of large websites, where fonts and color information were added to every single page, became a long and expensive process • To solve this problem, theWorld Wide Web Consortium (W3C) created CSS that removed the style formatting from the HTML page
  • 13. CSS Syntax • A CSS rule-set consists of a selector and a declaration block: H1 {color:blue; font-size:12px;} Selector Declaration Declaration Property Value Property Value
  • 14. Continued... • The selector points to the HTML element you want to style • The declaration block contains one or more declarations separated by semicolons • Each declaration includes a CSS property name and a value, separated by semicolon • A CSS declaration always ends with a semicolon and declaration blocks are surrounded by curly braces
  • 15. CSS Selectors • CSS selectors are used to “find” (or select) HTML elements based on their element name, id, class, attribute and more
  • 16. Types of CSS Selectors • There are 3 types of CSS selectors • Element Selector • Id Selector • Class Selector • Child Selector • Attribute Selector
  • 17. Continued… • Element Selector • The element selector selects elements based on the element name. • Id Selector • The id selector used the id attribute of an HTML element to select a specific element. • The id of an element should be unique within a page, so the id selector is used to select one unique element. • To select an element with a specific id, write a hash character, followed by the id of the element.
  • 18. Continued… • Class Selector • The class selector selects elements with a specific class attribute. • To select elements with a specific class, write a period character, followed by the name of the class. .center {text-align: center; color: red;} • You can also specify that only specific HTML elements should be affected by a class. p. center {text-align: center; color: red;} • HTML elements can also refer to more than one class. <p class=“center large”>This paragraph refers to two classes</p>
  • 19. Continued… • Child Selector body > p {color: #000000;} • Attribute Selector • You can also apply styles to HTML elements with particular attributes • input[type=“text”] {color: #000000;}
  • 20. Grouping Selectors • If you have elements with the same style definitions, like • h1 {text-align: center; color: red;} • h2 {text-align: center; color: red;} • p {text-align: center; color: red;} • It will be better to group the selectors, to minimize the code. • To group selectors, separate each selector with a comma. • h1, h2, p {text-align: center; color: red;}
  • 21. CSS Comments • Comments are used to explain the code, and may help when you edit the source code at a later date • Comments are ignored by browsers • A CSS comment starts with /* and ends with */ • Single Line and Multiline Comments