SlideShare a Scribd company logo
1 of 22
Download to read offline
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

More Related Content

What's hot

Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basicsEliran Eliassy
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 CssAbhishek Kesharwani
 
HTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryHTML/CSS/java Script/Jquery
HTML/CSS/java Script/JqueryFAKHRUN NISHA
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/jsKnoldus Inc.
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSSShehzad Yaqoob
 
HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!Syahmi RH
 
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 ScriptFahim Abdullah
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 CssAbhishek Kesharwani
 
Css Basics
Css BasicsCss Basics
Css BasicsJay Patel
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS Dave Kelly
 
Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Cascading Style Sheets - Part 01
Cascading Style Sheets - Part 01Hatem Mahmoud
 
Introduction to Cascading Style Sheets
Introduction to Cascading Style SheetsIntroduction to Cascading Style Sheets
Introduction to Cascading Style SheetsTushar Joshi
 

What's hot (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
 

Similar to 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
 
Css introduction
Css  introductionCss  introduction
Css introductionvishnu murthy
 
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
 
Cascading Style Sheet
Cascading Style SheetCascading Style Sheet
Cascading Style SheetMeenakshi Paul
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to cssJoseph Gabriel
 
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
 

Similar to 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
 

Recently uploaded

👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...rajveerescorts2022
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Delhi Call girls
 
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...Any kyc Account
 
Call Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service Bangaloreamitlee9823
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒anilsa9823
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsMichael W. Hawkins
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...lizamodels9
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756dollysharma2066
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxWorkforce Group
 

Recently uploaded (20)

👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
 
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
 
Call Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call đź‘— 7737669865 đź‘— Top Class Call Girl Service Bangalore
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael Hawkins
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pillsMifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 

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