SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
Web Programming and
Design
CSS (Cascading Style Sheet)
By : Gheyath M. Othman
Introduction to CSS (Cascading Style Sheet)
2
What is CSS ?
• CSS stands for Cascading Style Sheets
• 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
all at once
• External style sheets are stored in CSS files
Introduction to CSS (Cascading Style Sheet)
3
Som advantages of CSS:
• Save time
• Load page faster
• Easy maintenance
• Superior(larger) styles to HTML
• Multiple device compatibility
• Global web standards
Introduction to CSS (Cascading Style Sheet)
4
Who Creates and Maintains CSS?
CSS is created and maintained through a group of people within the W3C
called the CSS Working Group. The CSS Working Group creates documents
called specifications. When a specification has been discussed and officially
ratified by W3C members, it becomes a recommendation.
NOTE: The World Wide Web Consortium, or W3C is a group that makes recommendations
about how the Internet works and how it should evolve.
CSS Syntax
5
A CSS rule set consists of a selector and a declaration block.
• 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 property name and a value assigned to
property, separated by a colon.
In the following example all <p> elements will be center-aligned, with a red text
color:
<!DOCTYPE html>
<html>
<head>
<style>
p {
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Hello World!</p>
<p>This paragraph is styled with CSS.</p>
</body></html>
e1_first-ex>>
CSS Syntax
6
NOTE: To make the CSS code more readable,
you can put one declaration on each line.
• CSS selectors allow you to select and manipulate HTML elements.
• CSS selectors are used to "find" (or select) HTML elements based on their
id, class, type, attributes and more.
CSS Selectors
7
Element Selector:
▪ Element selector selects elements based on the element name. You can
select all <p> elements on a page like this: e2_element-selector>>
CSS Element Selector
8
<!DOCTYPE html><html>
<head>
<style>
p {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p>All paragraphs will be affected </p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
id Selectors:
▪ The id selector uses the id attribute of an HTML element to select a specific
element.
▪ An id should be unique within a page, so the id selector is used if you want to
select a single, unique element.
▪ Use a hash character followed by the id element. “#id_name” LIKE:
#red {
text-align: center;
color: red;
}
CSS id Selector
9
NOTE: ID name must not start with a number!.
Also as pointed that id should be unique because java script is care about that..
id Selector example:
CSS id Selector
10
<!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the
style.</p>
</body>
</html>
e3_id-selector>>
class Selectors:
▪ The class selector selects elements with a specific class attribute.
▪ Unlike id selector, classes are not unique, so the same class can be used for
multiple elements.
▪ Use a period character(.) followed by the class name. “.class_name” LIKE:
.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;
}
CSS Class Selector
11NOTE: CLASS name must not start with a number!
class selector example: e4_class-selector>> e5_class-selector1>>
CSS Class Selector
12
<!DOCTYPE html><html><head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">Red and center-aligned
heading</h1>
<p class="center">Red and center-aligned
paragraph.</p>
</body></html>
<!DOCTYPE html><html><head>
<style>
p.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">This heading will not be
affected</h1>
<p class="center">This paragraph will be red
and center-aligned.</p>
</body></html>
CSS Universal Selector
13
The universal selector is an asterisk; it is like a wildcard and matches all element
types in the document.
*{CSS code..}
If you want a rule to apply to all elements, you can use this selector. Sometimes it
is used for default values that will apply to the whole of the document (such as a
font - family and font - size ) unless another more specific selector indicates that
an element should use different values for these same properties.
<!DOCTYPE html><html><head>
<style type="text/css">
*{ color: red; font-size: 25px;}
</style>
</head>
<body>
<p>this is a paragraph</p>
<span>this is a span</span>
<h1>this is heading</h1>
</body></html>
CSS Attribute Selector
14
Attribute Selector:
It is possible to style HTML elements that have specific attributes or attribute
values.
[attribute] Selector
The [attribute] selector is used to select elements with a specified attribute.
selector[attribute] { CSS code..}
[attribute="value"] Selector
The [attribute="value"] selector is used to select elements with a specified
attribute and value.
selector[attribute=“value”] { CSS code..}
Attribute example(1):
CSS Attribute Selector
15
<!DOCTYPE html><html><head>
<style>
a[target] {
background-color: yellow;
}
</style>
</head>
<body>
<p>The links with a target attribute gets a yellow background:</p>
<a href=“www.w3schools.com ">w3schools.com</a>
<a href="http://www.disney.com" target="_blank">disney.com</a>
<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a>
body></html>
e1_attribute
Attribute example(2):
CSS Attribute Selector
16
<!DOCTYPE html><html><head>
<style>
a[target=_blank] {
background-color: yellow;
}
</style>
</head>
<body>
<p>The link with target="_blank" gets a yellow background:</p>
<a href="http://www.example.com">example.com</a>
<a href="http://www.disney.com" target="_blank">disney.com</a>
<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a>
body></html>
e2_attribute-value
CSS Attribute Selectors
17
There are others like:
• CSS [attribute~="value"] Selector: select elements with an attribute value
containing a specified word.(the word must be separated with others by space)
• CSS [attribute|="value"] Selector : select elements with the specified
attribute starting with the specified value.
• CSS [attribute^="value"] Selector :select elements whose attribute value
begins with a specified value.
• CSS [attribute$="value"] Selector :select elements whose attribute value ends
with a specified value.
• CSS [attribute*="value"] Selector :select elements whose attribute value
contains a specified value.
e3_mor-attr-sel
Note: The value has to be a whole word, either alone, like class="top", or followed by a hyphen( - ), like
class="top-text"!
Note: The value does not have to be a whole word!
Note: The value does not have to be a whole word!
Note: The value does not have to be a whole word!
CSS Combinators Selector
18
• A combinator is something that explains the relationship between the selectors.
• A CSS selector can contain more than one simple selector. Between the simple
selectors, we can include a combinator.
• There are four different combinators in CSS3:
1. descendant selector(space):matches all elements that are descendants of a
specified element.
2. child selector(>) :selects all elements that are the immediate children of a
specified element.
3. adjacent sibling selector(+):selects all elements that are the adjacent
siblings of a specified element.
4. general sibling selector (~):selects all elements that are siblings of a
specified element.
div p { background-color: yellow;}
div > p { background-color: yellow;}
div + p { background-color: yellow;}
div ~ p { background-color: yellow;}
body
h1
i
p
i
Combinators example(1) : descendant selector(space)
CSS Combinators Selector
19
<!DOCTYPE html><html><head>
<style>
div p {
background-color: yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
<span><p>Paragraph 3 in the div.</p></span>
</div>
<p>Paragraph 4. Not in a div.</p>
<p>Paragraph 5. Not in a div.</p>
body></html>
e1_combinators
Combinators example(2) : child selector(>)
CSS Combinators Selector
20
<!DOCTYPE html><html><head>
<style>
div > p {
background-color: yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
<span><p>Paragraph 3 in the div.</p></span>
<!-- not Child but Descendant -->
</div>
<p>Paragraph 4. Not in a div.</p>
<p>Paragraph 5. Not in a div.</p>
body></html>
e2_combinators
Combinators example(3) : adjacent sibling selector (+)
CSS Combinators Selector
21
<!DOCTYPE html><html><head>
<style>
div + p {
background-color: yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
</div>
<p>Paragraph 3. Not in a div.</p>
<p>Paragraph 4. Not in a div.</p>
body></html>
e3_combinators
Combinators example(4) : general sibling selector(~)
CSS Combinators Selector
22
<!DOCTYPE html><html><head>
<style>
div ~ p {
background-color: yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph 1 in the div.</p>
<p>Paragraph 2 in the div.</p>
</div>
<p>Paragraph 3. Not in a div.</p>
<p>Paragraph 4. Not in a div.</p>
body></html>
e4_combinators

Weitere ähnliche Inhalte

Was ist angesagt? (20)

TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
Css notes
Css notesCss notes
Css notes
 
HTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryHTML/CSS/java Script/Jquery
HTML/CSS/java Script/Jquery
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
html-css
html-csshtml-css
html-css
 
Css
CssCss
Css
 
Html training slide
Html training slideHtml training slide
Html training slide
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!
 
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
 
CSS
CSSCSS
CSS
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
Css Basics
Css BasicsCss Basics
Css Basics
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style Sheets
 

Ähnlich wie Web Design Course: CSS lecture 1

Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3Anjan Mahanta
 
Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3Anjan Mahanta
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssTesfaye Yenealem
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSSispkosova
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)Rafi Haidari
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...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 Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jqueryvaluebound
 
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.pptxalvindalejoyosa1
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style SheetsMukesh Tekwani
 
Css introduction
Css introductionCss introduction
Css introductionSridhar P
 
Css tutorial
Css tutorialCss tutorial
Css tutorialvedaste
 

Ähnlich wie Web Design Course: CSS lecture 1 (20)

Lecture-6.pptx
Lecture-6.pptxLecture-6.pptx
Lecture-6.pptx
 
CSS.pdf
CSS.pdfCSS.pdf
CSS.pdf
 
Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3
 
Web Development Using CSS3
Web Development Using CSS3Web Development Using CSS3
Web Development Using CSS3
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
 
Html Styles-CSS
Html Styles-CSSHtml Styles-CSS
Html Styles-CSS
 
Turorial css
Turorial cssTurorial css
Turorial css
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
 
Css introduction
Css  introductionCss  introduction
Css introduction
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...Cascading Styling Sheets(CSS) simple design language intended to transform th...
Cascading Styling Sheets(CSS) simple design language intended to transform th...
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style Sheet
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Css
CssCss
Css
 
Introduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jquery
 
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
 
Unit 2.1
Unit 2.1Unit 2.1
Unit 2.1
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Css introduction
Css introductionCss introduction
Css introduction
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 

Kürzlich hochgeladen

Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentationuneakwhite
 
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGpr788182
 
Cannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 UpdatedCannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 UpdatedCannaBusinessPlans
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...pujan9679
 
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165meghakumariji156
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting
 
Falcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon investment
 
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...ssuserf63bd7
 
Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...
Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...
Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...pujan9679
 
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAIGetting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAITim Wilson
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPanhandleOilandGas
 
Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel
 
Kalyan Call Girl 98350*37198 Call Girls in Escort service book now
Kalyan Call Girl 98350*37198 Call Girls in Escort service book nowKalyan Call Girl 98350*37198 Call Girls in Escort service book now
Kalyan Call Girl 98350*37198 Call Girls in Escort service book nowranineha57744
 
CROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NSCROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NSpanmisemningshen123
 
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxQSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxDitasDelaCruz
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1kcpayne
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Availablepr788182
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Adnet Communications
 
New 2024 Cannabis Edibles Investor Pitch Deck Template
New 2024 Cannabis Edibles Investor Pitch Deck TemplateNew 2024 Cannabis Edibles Investor Pitch Deck Template
New 2024 Cannabis Edibles Investor Pitch Deck TemplateCannaBusinessPlans
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...daisycvs
 

Kürzlich hochgeladen (20)

Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur CALL GIRL❤7091819311❤CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
 
Cannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 UpdatedCannabis Legalization World Map: 2024 Updated
Cannabis Legalization World Map: 2024 Updated
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
 
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Falcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business Potential
 
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
Horngren’s Cost Accounting A Managerial Emphasis, Canadian 9th edition soluti...
 
Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...
Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...
Chennai Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Av...
 
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAIGetting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation Final
 
Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024
 
Kalyan Call Girl 98350*37198 Call Girls in Escort service book now
Kalyan Call Girl 98350*37198 Call Girls in Escort service book nowKalyan Call Girl 98350*37198 Call Girls in Escort service book now
Kalyan Call Girl 98350*37198 Call Girls in Escort service book now
 
CROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NSCROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NS
 
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptxQSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
QSM Chap 10 Service Culture in Tourism and Hospitality Industry.pptx
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
 
New 2024 Cannabis Edibles Investor Pitch Deck Template
New 2024 Cannabis Edibles Investor Pitch Deck TemplateNew 2024 Cannabis Edibles Investor Pitch Deck Template
New 2024 Cannabis Edibles Investor Pitch Deck Template
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 

Web Design Course: CSS lecture 1

  • 1. Web Programming and Design CSS (Cascading Style Sheet) By : Gheyath M. Othman
  • 2. Introduction to CSS (Cascading Style Sheet) 2 What is CSS ? • CSS stands for Cascading Style Sheets • 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 all at once • External style sheets are stored in CSS files
  • 3. Introduction to CSS (Cascading Style Sheet) 3 Som advantages of CSS: • Save time • Load page faster • Easy maintenance • Superior(larger) styles to HTML • Multiple device compatibility • Global web standards
  • 4. Introduction to CSS (Cascading Style Sheet) 4 Who Creates and Maintains CSS? CSS is created and maintained through a group of people within the W3C called the CSS Working Group. The CSS Working Group creates documents called specifications. When a specification has been discussed and officially ratified by W3C members, it becomes a recommendation. NOTE: The World Wide Web Consortium, or W3C is a group that makes recommendations about how the Internet works and how it should evolve.
  • 5. CSS Syntax 5 A CSS rule set consists of a selector and a declaration block. • 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 property name and a value assigned to property, separated by a colon.
  • 6. In the following example all <p> elements will be center-aligned, with a red text color: <!DOCTYPE html> <html> <head> <style> p { color: red; text-align: center; } </style> </head> <body> <p>Hello World!</p> <p>This paragraph is styled with CSS.</p> </body></html> e1_first-ex>> CSS Syntax 6 NOTE: To make the CSS code more readable, you can put one declaration on each line.
  • 7. • CSS selectors allow you to select and manipulate HTML elements. • CSS selectors are used to "find" (or select) HTML elements based on their id, class, type, attributes and more. CSS Selectors 7
  • 8. Element Selector: ▪ Element selector selects elements based on the element name. You can select all <p> elements on a page like this: e2_element-selector>> CSS Element Selector 8 <!DOCTYPE html><html> <head> <style> p { text-align: center; color: red; } </style> </head> <body> <p>All paragraphs will be affected </p> <p id="para1">Me too!</p> <p>And me!</p> </body> </html>
  • 9. id Selectors: ▪ The id selector uses the id attribute of an HTML element to select a specific element. ▪ An id should be unique within a page, so the id selector is used if you want to select a single, unique element. ▪ Use a hash character followed by the id element. “#id_name” LIKE: #red { text-align: center; color: red; } CSS id Selector 9 NOTE: ID name must not start with a number!. Also as pointed that id should be unique because java script is care about that..
  • 10. id Selector example: CSS id Selector 10 <!DOCTYPE html> <html> <head> <style> #para1 { text-align: center; color: red; } </style> </head> <body> <p id="para1">Hello World!</p> <p>This paragraph is not affected by the style.</p> </body> </html> e3_id-selector>>
  • 11. class Selectors: ▪ The class selector selects elements with a specific class attribute. ▪ Unlike id selector, classes are not unique, so the same class can be used for multiple elements. ▪ Use a period character(.) followed by the class name. “.class_name” LIKE: .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; } CSS Class Selector 11NOTE: CLASS name must not start with a number!
  • 12. class selector example: e4_class-selector>> e5_class-selector1>> CSS Class Selector 12 <!DOCTYPE html><html><head> <style> .center { text-align: center; color: red; } </style> </head> <body> <h1 class="center">Red and center-aligned heading</h1> <p class="center">Red and center-aligned paragraph.</p> </body></html> <!DOCTYPE html><html><head> <style> p.center { text-align: center; color: red; } </style> </head> <body> <h1 class="center">This heading will not be affected</h1> <p class="center">This paragraph will be red and center-aligned.</p> </body></html>
  • 13. CSS Universal Selector 13 The universal selector is an asterisk; it is like a wildcard and matches all element types in the document. *{CSS code..} If you want a rule to apply to all elements, you can use this selector. Sometimes it is used for default values that will apply to the whole of the document (such as a font - family and font - size ) unless another more specific selector indicates that an element should use different values for these same properties. <!DOCTYPE html><html><head> <style type="text/css"> *{ color: red; font-size: 25px;} </style> </head> <body> <p>this is a paragraph</p> <span>this is a span</span> <h1>this is heading</h1> </body></html>
  • 14. CSS Attribute Selector 14 Attribute Selector: It is possible to style HTML elements that have specific attributes or attribute values. [attribute] Selector The [attribute] selector is used to select elements with a specified attribute. selector[attribute] { CSS code..} [attribute="value"] Selector The [attribute="value"] selector is used to select elements with a specified attribute and value. selector[attribute=“value”] { CSS code..}
  • 15. Attribute example(1): CSS Attribute Selector 15 <!DOCTYPE html><html><head> <style> a[target] { background-color: yellow; } </style> </head> <body> <p>The links with a target attribute gets a yellow background:</p> <a href=“www.w3schools.com ">w3schools.com</a> <a href="http://www.disney.com" target="_blank">disney.com</a> <a href="http://www.wikipedia.org" target="_top">wikipedia.org</a> body></html> e1_attribute
  • 16. Attribute example(2): CSS Attribute Selector 16 <!DOCTYPE html><html><head> <style> a[target=_blank] { background-color: yellow; } </style> </head> <body> <p>The link with target="_blank" gets a yellow background:</p> <a href="http://www.example.com">example.com</a> <a href="http://www.disney.com" target="_blank">disney.com</a> <a href="http://www.wikipedia.org" target="_top">wikipedia.org</a> body></html> e2_attribute-value
  • 17. CSS Attribute Selectors 17 There are others like: • CSS [attribute~="value"] Selector: select elements with an attribute value containing a specified word.(the word must be separated with others by space) • CSS [attribute|="value"] Selector : select elements with the specified attribute starting with the specified value. • CSS [attribute^="value"] Selector :select elements whose attribute value begins with a specified value. • CSS [attribute$="value"] Selector :select elements whose attribute value ends with a specified value. • CSS [attribute*="value"] Selector :select elements whose attribute value contains a specified value. e3_mor-attr-sel Note: The value has to be a whole word, either alone, like class="top", or followed by a hyphen( - ), like class="top-text"! Note: The value does not have to be a whole word! Note: The value does not have to be a whole word! Note: The value does not have to be a whole word!
  • 18. CSS Combinators Selector 18 • A combinator is something that explains the relationship between the selectors. • A CSS selector can contain more than one simple selector. Between the simple selectors, we can include a combinator. • There are four different combinators in CSS3: 1. descendant selector(space):matches all elements that are descendants of a specified element. 2. child selector(>) :selects all elements that are the immediate children of a specified element. 3. adjacent sibling selector(+):selects all elements that are the adjacent siblings of a specified element. 4. general sibling selector (~):selects all elements that are siblings of a specified element. div p { background-color: yellow;} div > p { background-color: yellow;} div + p { background-color: yellow;} div ~ p { background-color: yellow;} body h1 i p i
  • 19. Combinators example(1) : descendant selector(space) CSS Combinators Selector 19 <!DOCTYPE html><html><head> <style> div p { background-color: yellow; } </style> </head> <body> <div> <p>Paragraph 1 in the div.</p> <p>Paragraph 2 in the div.</p> <span><p>Paragraph 3 in the div.</p></span> </div> <p>Paragraph 4. Not in a div.</p> <p>Paragraph 5. Not in a div.</p> body></html> e1_combinators
  • 20. Combinators example(2) : child selector(>) CSS Combinators Selector 20 <!DOCTYPE html><html><head> <style> div > p { background-color: yellow; } </style> </head> <body> <div> <p>Paragraph 1 in the div.</p> <p>Paragraph 2 in the div.</p> <span><p>Paragraph 3 in the div.</p></span> <!-- not Child but Descendant --> </div> <p>Paragraph 4. Not in a div.</p> <p>Paragraph 5. Not in a div.</p> body></html> e2_combinators
  • 21. Combinators example(3) : adjacent sibling selector (+) CSS Combinators Selector 21 <!DOCTYPE html><html><head> <style> div + p { background-color: yellow; } </style> </head> <body> <div> <p>Paragraph 1 in the div.</p> <p>Paragraph 2 in the div.</p> </div> <p>Paragraph 3. Not in a div.</p> <p>Paragraph 4. Not in a div.</p> body></html> e3_combinators
  • 22. Combinators example(4) : general sibling selector(~) CSS Combinators Selector 22 <!DOCTYPE html><html><head> <style> div ~ p { background-color: yellow; } </style> </head> <body> <div> <p>Paragraph 1 in the div.</p> <p>Paragraph 2 in the div.</p> </div> <p>Paragraph 3. Not in a div.</p> <p>Paragraph 4. Not in a div.</p> body></html> e4_combinators