SlideShare a Scribd company logo
Web Programming and
Design
CSS (Cascading Style Sheet)
By: Gheyath M. Othman
CSS Comments
• A CSS comment starts with /* and ends with */. Comments can also span
multiple lines: like
CSS Comments
2
<!DOCTYPE html><html><head>
<style>
p {
color: red;
/* This is a single-line comment */
text-align: center;
}
/* This is
a multi-line comment */
</style>
</head>
<body>
<p>This paragraph is styled with CSS.</p>
<p>CSS comments are not shown in the output.</p>
</body></html>
You can group selectors. Separate each selector with a comma.
Grouping Selectors
3
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p {
text-align: center;
color: red;
}
h1, h2, p {
text-align: center;
color: red;
}
<!DOCTYPE html><html><head>
<style>
h1, h2, p {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<h2>Smaller heading!</h2>
<p>This is a paragraph.</p>
</body></html>
When a browser reads a style sheet, it will format the document according to
the information in the style sheet.
Three Ways to Insert CSS:
Ways of Inserting CSS Styles
4
There are three ways of inserting a style sheet:
• External style sheet
• Internal style sheet
• Inline style
• The style sheet file must be saved with a .css extension. The file should not
contain any html tags.
External Style Sheet:
Ways of Inserting a Style Sheet
5
• With an external style sheet, you can change the look of an entire website
by changing just one file!
• Each page must include a reference to the external style sheet file inside
the <link> element. The <link> element goes inside the head section:
<head><link rel="stylesheet" type="text/css" href="mystyle.css"></head>
HTML files
CSS file
With
(mystyle.css)
HTML filesHTML filesHTML filesHTML files
e6_external-style>>
Ways of Inserting a Style Sheet
6
External style sheet example:
<!DOCTYPE html><html>
<head>
<link rel="stylesheet" type="text/css" href=“mystyle.css">
</head>
<body>
<h1>This heading will be affected by external styles.</h1>
</body></html>
HTML file
body{ background-color:skyblue}
h1{
color:red;
text-align:center;
}
CSS file (mystyle.css)
Internal Style Sheet:
Ways of Inserting a Style Sheet
7
• An internal style sheet may be used if one single page has a unique style.
• Internal styles are defined within the <style> element, inside the head
section of an HTML page:
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
}
</style>
</head
Internal Style Sheet example:
Ways of Inserting a Style Sheet
8
e7_enternal-style>>
<!DOCTYPE html><html>
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
text-align: center;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body></html>
CSS style used inside the page in head section
Inline Style Sheet:
Ways of Inserting a Style Sheet
9
• An inline style may be used to apply a unique style for a single element.
• An inline style loses many of the advantages of a style sheet (by mixing
content with presentation).
• To use inline styles, add the style attribute to the relevant tag. The style
attribute can contain any CSS property.
<h1 style="CSS code…">This is a heading.</h1>
Inline Style Sheet example:
Ways of Inserting a Style Sheet
10
e8_inline-style>>
<!DOCTYPE html><html>
<body>
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>
<p>This is a paragraph.</p>
</body></html>
Multiple Styles Will Cascade into One
11
Styles can be specified:
• in an external CSS file
• inside the <head> section of an HTML page
• inside an HTML element
Cascading order
Question//What style will be used when there is more than one style specified
for an HTML element?
Inline style (inside an HTML element) has the highest priority, which means that
it will override a style defined inside the <head> tag, or in an external style
sheet, or in a browser (a default value).
e9_priority-style>>
CSS Background
12
CSS background properties are used to define the background effects of an
element. CSS properties used for background effects are:
Property Description Values
background A shorthand property for
setting all background
properties
in one declaration
background-color
background-image
background-repeat
Background-attachment
Background-position
Background-color
e1_>> e1_1>>
Sets the background
color of an element
color-rgb
color-hex
color-name
transparent
Background-image
e2_>>
Sets an image as the
background
url(URL)
none
CSS Background
13
Property Description Values
Background-repeat
e3_>>
Sets if/how a
background image will
be repeated
repeat
repeat-x
repeat-y
no-repeat
Background-position
e4_>>
Sets the starting
position of a
background image
top left
top center
top right
center left
Center center
Center right
Bottom left
bottom center
bottom right
x% y%
Background-attachment
e5_>>
Sets whether a
background image is
fixed or scrolls with
the rest of the page
scroll
fixed
CSS Background Examples
14
Example-1-:page background
<!DOCTYPE html><html><head>
<style>
body { background-color: #b0c4de; }
</style>
</head>
<body>
<h1>My CSS web page!</h1>
<p>This is a background color example.</p>
</body></html>
Example-2-:elements background
<!DOCTYPE html><html><head>
<style>
h1 { background-color: #6495ed;}
div { background-color: #b0c4de;}
p { background-color: #e0ffff;}
</style>
</head><body>
<h1>CSS background-color example!</h1>
<div>This is a text inside a div element.
<p>This p has its own background color.</p>
We are still in the div element.</div>
</body></html>
e1_>> e1_1>>
CSS Background Examples
15
Example:background-image
<!DOCTYPE html><html><head>
<style>
body {
background-image: url("paper.gif");
}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body></html>
e2_>>
CSS Background Examples
16
Example:background-repeat
<!DOCTYPE html><html><head>
<style>
body {
background-image: url("paper.gif");
background-repeat: no-repeat;
}
</style>
</head>
<body>
<p>background repeat..</p>
</body></html>
You can use repeat-x
You can use repeat-y
You can use repeat
e3_>>
CSS Background Examples
17
Example:background-position
<!DOCTYPE html><html> <head>
<style>
body {
background-image: url("../img_flwr.gif");
background-position:center center;
background-repeat:no-repeat;
}
</style>
</head>
<body>
<p>background position..</p>
<p>background position..</p> <p>background
position..</p> <p>background position..</p>
<p>background position..</p>
<p>background position..</p>
</body></html>
e4_>>
Ad

More Related Content

What's hot (20)

HTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryHTML/CSS/java Script/Jquery
HTML/CSS/java Script/Jquery
FAKHRUN NISHA
 
CSS ppt
CSS pptCSS ppt
CSS ppt
Sanmuga Nathan
 
HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!
Syahmi RH
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
Abhishek Kesharwani
 
Web Engineering - Basic CSS Properties
Web Engineering - Basic CSS PropertiesWeb Engineering - Basic CSS Properties
Web Engineering - Basic CSS Properties
Nosheen Qamar
 
Web Engineering - Introduction to CSS
Web Engineering - Introduction to CSSWeb Engineering - Introduction to CSS
Web Engineering - Introduction to CSS
Nosheen Qamar
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
Fahim Abdullah
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
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
 
html-css
html-csshtml-css
html-css
Dhirendra Chauhan
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
Knoldus Inc.
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
Hatem Mahmoud
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style Sheets
Tushar Joshi
 
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 notes
Css notesCss notes
Css notes
Computer Hardware & Trouble shooting
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
WordPress Memphis
 
Css
CssCss
Css
actacademy
 
Css
CssCss
Css
actacademy
 

Similar to Web Design Course: CSS lecture 2 (20)

CSS notes
CSS notesCSS notes
CSS notes
Rajendra Prasad
 
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
4_css_intro.pptx.  this ppt is based on css which is the required of web deve...4_css_intro.pptx.  this ppt is based on css which is the required of web deve...
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
sindwanigripsi
 
Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3
Anjan Mahanta
 
Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3
Anjan Mahanta
 
Css introduction
Css  introductionCss  introduction
Css introduction
vishnu murthy
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Folasade Adedeji
 
CSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students StudyingCSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students Studying
nirmala119429
 
properties of css.pptx power pointpresentation
properties of css.pptx power pointpresentationproperties of css.pptx power pointpresentation
properties of css.pptx power pointpresentation
Coderkids
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
What is CSS.pptx power point presentation
What is CSS.pptx power point presentationWhat is CSS.pptx power point presentation
What is CSS.pptx power point presentation
Coderkids
 
CSS.pdf
CSS.pdfCSS.pdf
CSS.pdf
SoniaJoshi25
 
Css Basics
Css BasicsCss Basics
Css Basics
Jay Patel
 
CSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptxCSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptx
Ajanya5
 
CSS ppt of cascading Style sheet for beginners.pptx
CSS ppt of cascading Style sheet for beginners.pptxCSS ppt of cascading Style sheet for beginners.pptx
CSS ppt of cascading Style sheet for beginners.pptx
HarshSahu509641
 
cascading style sheets- About cascading style sheets on the selectors
cascading style sheets- About cascading style sheets on the selectorscascading style sheets- About cascading style sheets on the selectors
cascading style sheets- About cascading style sheets on the selectors
JayanthiM19
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
Meenakshi Paul
 
Cascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSSCascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Joseph Gabriel
 
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptxChapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
4_css_intro.pptx.  this ppt is based on css which is the required of web deve...4_css_intro.pptx.  this ppt is based on css which is the required of web deve...
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
sindwanigripsi
 
Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3
Anjan Mahanta
 
Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3
Anjan Mahanta
 
CSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students StudyingCSS Tutorial For Basic Students Studying
CSS Tutorial For Basic Students Studying
nirmala119429
 
properties of css.pptx power pointpresentation
properties of css.pptx power pointpresentationproperties of css.pptx power pointpresentation
properties of css.pptx power pointpresentation
Coderkids
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
What is CSS.pptx power point presentation
What is CSS.pptx power point presentationWhat is CSS.pptx power point presentation
What is CSS.pptx power point presentation
Coderkids
 
CSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptxCSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptx
Ajanya5
 
CSS ppt of cascading Style sheet for beginners.pptx
CSS ppt of cascading Style sheet for beginners.pptxCSS ppt of cascading Style sheet for beginners.pptx
CSS ppt of cascading Style sheet for beginners.pptx
HarshSahu509641
 
cascading style sheets- About cascading style sheets on the selectors
cascading style sheets- About cascading style sheets on the selectorscascading style sheets- About cascading style sheets on the selectors
cascading style sheets- About cascading style sheets on the selectors
JayanthiM19
 
Cascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSSCascading style sheet, CSS Box model, Table in CSS
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptxChapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
Chapter_1_Web_Technologies_Basics (CSS)_Part_2.pptx
eyasu6
 
Ad

Recently uploaded (20)

NewBase 28 April 2025 Energy News issue - 1783 by Khaled Al Awadi_compressed...
NewBase 28 April 2025  Energy News issue - 1783 by Khaled Al Awadi_compressed...NewBase 28 April 2025  Energy News issue - 1783 by Khaled Al Awadi_compressed...
NewBase 28 April 2025 Energy News issue - 1783 by Khaled Al Awadi_compressed...
Khaled Al Awadi
 
CGG Deck English - Apr 2025-edit (1).pptx
CGG Deck English - Apr 2025-edit (1).pptxCGG Deck English - Apr 2025-edit (1).pptx
CGG Deck English - Apr 2025-edit (1).pptx
China_Gold_International_Resources
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
Disinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key FindingsDisinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key Findings
MariumAbdulhussein
 
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
TheoRuby
 
TNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining Presentation
TNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining PresentationTNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining Presentation
TNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining Presentation
Kirill Klip
 
Theory of Cognitive Chasms: Failure Modes of GenAI Adoption
Theory of Cognitive Chasms: Failure Modes of GenAI AdoptionTheory of Cognitive Chasms: Failure Modes of GenAI Adoption
Theory of Cognitive Chasms: Failure Modes of GenAI Adoption
Dr. Tathagat Varma
 
Salesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptxSalesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptx
reinbauwens1
 
Viktor Svystunov: Your Team Can Do More (UA)
Viktor Svystunov: Your Team Can Do More (UA)Viktor Svystunov: Your Team Can Do More (UA)
Viktor Svystunov: Your Team Can Do More (UA)
Lviv Startup Club
 
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
AMITKUMARVERMA479091
 
Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...
Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...
Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...
David Teece
 
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOTINTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
CA Suvidha Chaplot
 
Freeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & GrowthFreeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & Growth
chanderdeepseoexpert
 
TNR Gold Shotgun Gold Project Presentation
TNR Gold Shotgun Gold Project PresentationTNR Gold Shotgun Gold Project Presentation
TNR Gold Shotgun Gold Project Presentation
Kirill Klip
 
Treis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IVTreis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IV
aparicioregina7
 
Solaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdfSolaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdf
pchambers2
 
Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Cloud Stream Part II Mobile Hub V1 Hub Agency.pdfCloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Brij Consulting, LLC
 
Entrepreneurship: Practicum on Business Plan.ppt
Entrepreneurship: Practicum on Business Plan.pptEntrepreneurship: Practicum on Business Plan.ppt
Entrepreneurship: Practicum on Business Plan.ppt
Tribhuvan University
 
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
QX Accounting Services Ltd
 
The Essential Guide to Process Diagrams for Smarter Business Management
The Essential Guide to Process Diagrams for Smarter Business ManagementThe Essential Guide to Process Diagrams for Smarter Business Management
The Essential Guide to Process Diagrams for Smarter Business Management
RUPAL AGARWAL
 
NewBase 28 April 2025 Energy News issue - 1783 by Khaled Al Awadi_compressed...
NewBase 28 April 2025  Energy News issue - 1783 by Khaled Al Awadi_compressed...NewBase 28 April 2025  Energy News issue - 1783 by Khaled Al Awadi_compressed...
NewBase 28 April 2025 Energy News issue - 1783 by Khaled Al Awadi_compressed...
Khaled Al Awadi
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
Disinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key FindingsDisinformation in Society Report 2025 Key Findings
Disinformation in Society Report 2025 Key Findings
MariumAbdulhussein
 
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
Web Design Creating User-Friendly and Visually Engaging Websites - April 2025...
TheoRuby
 
TNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining Presentation
TNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining PresentationTNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining Presentation
TNR Gold Los Azules Copper NSR Royalty Holding with McEwen Mining Presentation
Kirill Klip
 
Theory of Cognitive Chasms: Failure Modes of GenAI Adoption
Theory of Cognitive Chasms: Failure Modes of GenAI AdoptionTheory of Cognitive Chasms: Failure Modes of GenAI Adoption
Theory of Cognitive Chasms: Failure Modes of GenAI Adoption
Dr. Tathagat Varma
 
Salesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptxSalesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptx
reinbauwens1
 
Viktor Svystunov: Your Team Can Do More (UA)
Viktor Svystunov: Your Team Can Do More (UA)Viktor Svystunov: Your Team Can Do More (UA)
Viktor Svystunov: Your Team Can Do More (UA)
Lviv Startup Club
 
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
PREDICTION%20AND%20ANALYSIS%20OF%20ADMET%20PROPERTIES%20OF%20NEW%20MOLECULE%2...
AMITKUMARVERMA479091
 
Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...
Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...
Understanding Dynamic Competition: Perspectives on Monopoly and Market Power ...
David Teece
 
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOTINTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
CA Suvidha Chaplot
 
Freeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & GrowthFreeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & Growth
chanderdeepseoexpert
 
TNR Gold Shotgun Gold Project Presentation
TNR Gold Shotgun Gold Project PresentationTNR Gold Shotgun Gold Project Presentation
TNR Gold Shotgun Gold Project Presentation
Kirill Klip
 
Treis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IVTreis & Friends One sheet - Portfolio IV
Treis & Friends One sheet - Portfolio IV
aparicioregina7
 
Solaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdfSolaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdf
pchambers2
 
Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Cloud Stream Part II Mobile Hub V1 Hub Agency.pdfCloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Cloud Stream Part II Mobile Hub V1 Hub Agency.pdf
Brij Consulting, LLC
 
Entrepreneurship: Practicum on Business Plan.ppt
Entrepreneurship: Practicum on Business Plan.pptEntrepreneurship: Practicum on Business Plan.ppt
Entrepreneurship: Practicum on Business Plan.ppt
Tribhuvan University
 
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
QX Accounting Services Ltd
 
The Essential Guide to Process Diagrams for Smarter Business Management
The Essential Guide to Process Diagrams for Smarter Business ManagementThe Essential Guide to Process Diagrams for Smarter Business Management
The Essential Guide to Process Diagrams for Smarter Business Management
RUPAL AGARWAL
 
Ad

Web Design Course: CSS lecture 2

  • 1. Web Programming and Design CSS (Cascading Style Sheet) By: Gheyath M. Othman
  • 2. CSS Comments • A CSS comment starts with /* and ends with */. Comments can also span multiple lines: like CSS Comments 2 <!DOCTYPE html><html><head> <style> p { color: red; /* This is a single-line comment */ text-align: center; } /* This is a multi-line comment */ </style> </head> <body> <p>This paragraph is styled with CSS.</p> <p>CSS comments are not shown in the output.</p> </body></html>
  • 3. You can group selectors. Separate each selector with a comma. Grouping Selectors 3 h1 { text-align: center; color: red; } h2 { text-align: center; color: red; } p { text-align: center; color: red; } h1, h2, p { text-align: center; color: red; } <!DOCTYPE html><html><head> <style> h1, h2, p { text-align: center; color: red; } </style> </head> <body> <h1>Hello World!</h1> <h2>Smaller heading!</h2> <p>This is a paragraph.</p> </body></html>
  • 4. When a browser reads a style sheet, it will format the document according to the information in the style sheet. Three Ways to Insert CSS: Ways of Inserting CSS Styles 4 There are three ways of inserting a style sheet: • External style sheet • Internal style sheet • Inline style
  • 5. • The style sheet file must be saved with a .css extension. The file should not contain any html tags. External Style Sheet: Ways of Inserting a Style Sheet 5 • With an external style sheet, you can change the look of an entire website by changing just one file! • Each page must include a reference to the external style sheet file inside the <link> element. The <link> element goes inside the head section: <head><link rel="stylesheet" type="text/css" href="mystyle.css"></head> HTML files CSS file With (mystyle.css) HTML filesHTML filesHTML filesHTML files
  • 6. e6_external-style>> Ways of Inserting a Style Sheet 6 External style sheet example: <!DOCTYPE html><html> <head> <link rel="stylesheet" type="text/css" href=“mystyle.css"> </head> <body> <h1>This heading will be affected by external styles.</h1> </body></html> HTML file body{ background-color:skyblue} h1{ color:red; text-align:center; } CSS file (mystyle.css)
  • 7. Internal Style Sheet: Ways of Inserting a Style Sheet 7 • An internal style sheet may be used if one single page has a unique style. • Internal styles are defined within the <style> element, inside the head section of an HTML page: <head> <style> body { background-color: linen; } h1 { color: maroon; } </style> </head
  • 8. Internal Style Sheet example: Ways of Inserting a Style Sheet 8 e7_enternal-style>> <!DOCTYPE html><html> <head> <style> body { background-color: linen; } h1 { color: maroon; text-align: center; } </style> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body></html> CSS style used inside the page in head section
  • 9. Inline Style Sheet: Ways of Inserting a Style Sheet 9 • An inline style may be used to apply a unique style for a single element. • An inline style loses many of the advantages of a style sheet (by mixing content with presentation). • To use inline styles, add the style attribute to the relevant tag. The style attribute can contain any CSS property. <h1 style="CSS code…">This is a heading.</h1>
  • 10. Inline Style Sheet example: Ways of Inserting a Style Sheet 10 e8_inline-style>> <!DOCTYPE html><html> <body> <h1 style="color:blue;margin-left:30px;">This is a heading.</h1> <p>This is a paragraph.</p> </body></html>
  • 11. Multiple Styles Will Cascade into One 11 Styles can be specified: • in an external CSS file • inside the <head> section of an HTML page • inside an HTML element Cascading order Question//What style will be used when there is more than one style specified for an HTML element? Inline style (inside an HTML element) has the highest priority, which means that it will override a style defined inside the <head> tag, or in an external style sheet, or in a browser (a default value). e9_priority-style>>
  • 12. CSS Background 12 CSS background properties are used to define the background effects of an element. CSS properties used for background effects are: Property Description Values background A shorthand property for setting all background properties in one declaration background-color background-image background-repeat Background-attachment Background-position Background-color e1_>> e1_1>> Sets the background color of an element color-rgb color-hex color-name transparent Background-image e2_>> Sets an image as the background url(URL) none
  • 13. CSS Background 13 Property Description Values Background-repeat e3_>> Sets if/how a background image will be repeated repeat repeat-x repeat-y no-repeat Background-position e4_>> Sets the starting position of a background image top left top center top right center left Center center Center right Bottom left bottom center bottom right x% y% Background-attachment e5_>> Sets whether a background image is fixed or scrolls with the rest of the page scroll fixed
  • 14. CSS Background Examples 14 Example-1-:page background <!DOCTYPE html><html><head> <style> body { background-color: #b0c4de; } </style> </head> <body> <h1>My CSS web page!</h1> <p>This is a background color example.</p> </body></html> Example-2-:elements background <!DOCTYPE html><html><head> <style> h1 { background-color: #6495ed;} div { background-color: #b0c4de;} p { background-color: #e0ffff;} </style> </head><body> <h1>CSS background-color example!</h1> <div>This is a text inside a div element. <p>This p has its own background color.</p> We are still in the div element.</div> </body></html> e1_>> e1_1>>
  • 15. CSS Background Examples 15 Example:background-image <!DOCTYPE html><html><head> <style> body { background-image: url("paper.gif"); } </style> </head> <body> <h1>Hello World!</h1> </body></html> e2_>>
  • 16. CSS Background Examples 16 Example:background-repeat <!DOCTYPE html><html><head> <style> body { background-image: url("paper.gif"); background-repeat: no-repeat; } </style> </head> <body> <p>background repeat..</p> </body></html> You can use repeat-x You can use repeat-y You can use repeat e3_>>
  • 17. CSS Background Examples 17 Example:background-position <!DOCTYPE html><html> <head> <style> body { background-image: url("../img_flwr.gif"); background-position:center center; background-repeat:no-repeat; } </style> </head> <body> <p>background position..</p> <p>background position..</p> <p>background position..</p> <p>background position..</p> <p>background position..</p> <p>background position..</p> </body></html> e4_>>