SlideShare a Scribd company logo
WEB DESIGN TRAINING 03
INTRODUCTION TO CASCADING
STYLE SHEETS(CSS)
Presented by Folasade Adedeji
Cascading Style Sheets
 A key tool in web design
 CSS is the sister technology to HTML that is
used to style web pages.
 CSS is used to control the style and layout of
multiple Web pages all at once.
 CSS defines HOW HTML elements are to be
displayed.
Cascading Style Sheets
 Styles are normally saved in external .css files
 External style sheets enable you to change the
appearance and layout of all the pages in a
Web site, just by editing one single file!
CSS Syntax
 A CSS rule has two main parts: a selector, and
one or more declarations:
Introduction to CSS
CSS Syntax
 A CSS declaration always ends with a
semicolon, and declaration groups are
surrounded by curly brackets:
 p {color:red;text-align:center;}
p
{
color:red;
text-align:center;
}
CSS Comment
 Comments are used to explain your code
 Comments are ignored by browsers.
 A CSS comment begins with "/*“
 and ends with "*/", for example:
/*This is a comment*/
p
{
text-align:center;
/*This is another comment*/
color:black;
font-family:arial;
}
CSS id and class
 The id selector is used to specify a style for a
single, unique element.
 The id selector uses the id attribute of the HTML
element, and is defined with a "#".
 The style rule below will be applied to the element
with id="para1":
#para1
{
text-align:center;
color:red;
}
Class selector
 The class selector is used to specify a style for a
group of elements. Unlike the id selector, the class
selector is most often used on several elements.
 This allows you to set a particular style for many
HTML elements with the same class.
 The class selector uses the HTML class attribute,
and is defined with a "."
 In the example below, all HTML elements with
class="center" will be center-aligned:
Example
.center {text-align:center;}
 You can also specify that only specific HTML
elements should be affected by a class.
 In the example below, all p elements with
class="center" will be center-aligned:
Example
p.center {text-align:center;}
How to Insert CSS
Three Ways to Insert CSS
There are three ways of inserting a style sheet:
 External style sheet
 Internal style sheet
 Inline style
External Style Sheet
 An external style sheet is used when the style is
applied to many pages.
 With an external style sheet, you can change the
look of an entire Web site by changing one file.
 Each page must link to the style sheet using the
<link> tag. The <link> tag goes inside the head
section:
<head>
<link rel="stylesheet" type="text/css"
href="mystyle.css">
</head>
 An external style sheet can be written in any
text editor.
 The file should not contain any html tags. Your
style sheet should be saved with a .css
extension.
An example of a style sheet file is shown below:
hr {color:sienna;}
p {margin-left:20px;}
body {background-
image:url("images/background.gif");}
Internal Style Sheet
 An internal style sheet should be used when a
single document has a unique style.
 You define internal styles in the head section of
an HTML page, by using the <style> tag, like this:
<head>
<style>
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back.gif");}
</style>
</head>
Inline Styles
 To use inline styles you use the style attribute
in the relevant tag. The style attribute can
contain any CSS property. The example shows
how to change the color and the left margin of
a paragraph:
 <p style="color:sienna;margin-left:20px;">This
is a paragraph.</p>
Multiple Style Sheets
 If some properties have been set for the same
selector in different style sheets, the values will
be inherited from the more specific style
sheet.
Multiple Style Sheets
For example, an external style sheet has these properties for the h3 selector:
h3
{
color:red;
text-align:left;
font-size:8pt;
}
And an internal style sheet has these properties for the h3 selector:
h3
{
text-align:right;
font-size:20pt;
}
If the page with the internal style sheet also links to the external style sheet the properties for h3 will
be:
color:red;
text-align:right;
font-size:20pt;
The color is inherited from the external style sheet and the text-alignment and the font-size is
replaced by the internal style sheet.
Cascading Order
 What style will be used when there is more than one style
specified for an HTML element?
 Generally speaking we can say that all the styles will
"cascade" into a new "virtual" style sheet by the following
rules, where number four has the highest priority:
 Browser default
 External style sheet
 Internal style sheet (in the head section)
 Inline style (inside an HTML element)
 So, an 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).
CSS Background
CSS background properties are used to define
the background effects of an element.
CSS properties used for background effects:
 background-color
 background-image
 background-repeat
 background-attachment
 background-position
Background Color
 The background-color property specifies the
background color of an element.
 The background color of a page is defined in
the body selector:
 Example
 body {background-color:#b0c4de;}
<!DOCTYPE html>
<html>
<head>
<style>
h1
{
background-color:#6495ed;
}
p
{
background-color:#e0ffff;
}
div
{
background-color:#b0c4de;
}
</style>
</head>
<body>
<h1>CSS background-color example!</h1>
<div>
This is a text inside a div element.
<p>This paragraph has its own background color.</p>
We are still in the div element.
</div>
</body>
Background Image
 The background-image property specifies an
image to use as the background of an
element.
 By default, the image is repeated so it covers
the entire element.
 The background image for a page can be set
like this:
 Example
 body {background-image:url("paper.gif");}
Background Image - Repeat
Horizontally or Vertically
 By default, the background-image property
repeats an image both horizontally and
vertically.
 Some images should be repeated only
horizontally or vertically, or they will look
strange, like this:
 Example
 body
{
background-image:url(“back2.png");
}
 If the image is repeated only horizontally
(repeat-x), the background will look better:
 Example
 body
{
background-image:url(“back2.png");
background-repeat:repeat-x;
}
Background Image - Set position
and no-repeat
 Showing the image only once is specified by
the background-repeat property:
 Example
 body
{
background-image:url(“me.png");
background-repeat:no-repeat;
}
 In the example above, the background image is
shown in the same place as the text. We want to
change the position of the image, so that it does not
disturb the text too much.
 The position of the image is specified by the
background-position property:
 Example
 body
{
background-image:url(“me.png");
background-repeat:no-repeat;
background-position:right top;
}
Background - Shorthand
property
 As you can see from the examples above, there
are many properties to consider when dealing with
backgrounds.
 To shorten the code, it is also possible to specify
all the properties in one single property. This is
called a shorthand property.
 The shorthand property for background is simply
"background":
 Example
 body {background:#ffffff url(“me.png") no-repeat
right top;}
 To be continued
Ad

More Related Content

What's hot (20)

CSS
CSSCSS
CSS
People Strategists
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
Sanjeev Kumar
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
WordPress Memphis
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
Ajay Khatri
 
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
HtmlHtml
Html
irshadahamed
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
Dave Kelly
 
Html
HtmlHtml
Html
Nandakumar Ganapathy
 
Html ppt
Html pptHtml ppt
Html ppt
santosh lamba
 
HTML & CSS Masterclass
HTML & CSS MasterclassHTML & CSS Masterclass
HTML & CSS Masterclass
Bernardo Raposo
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
vikasgaur31
 
Html ppt
Html pptHtml ppt
Html ppt
Iblesoft
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
Mario Hernandez
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
apnwebdev
 
CSS
CSSCSS
CSS
seedinteractive
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Css ppt
Css pptCss ppt
Css ppt
Nidhi mishra
 
Html5 semantics
Html5 semanticsHtml5 semantics
Html5 semantics
Webtech Learning
 

Similar to Introduction to CSS (20)

TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
Css introduction
Css  introductionCss  introduction
Css introduction
vishnu murthy
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
Programmer Blog
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
Rafi Haidari
 
CSS notes
CSS notesCSS notes
CSS notes
Rajendra Prasad
 
Css introduction
Css introductionCss introduction
Css introduction
Sridhar P
 
CSS
CSSCSS
CSS
DivyaKS12
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
Joseph Gabriel
 
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
 
properties of css.pptx power pointpresentation
properties of css.pptx power pointpresentationproperties of css.pptx power pointpresentation
properties of css.pptx power pointpresentation
Coderkids
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
cascading style sheets ppt.sildeshower phone view
cascading style sheets ppt.sildeshower phone viewcascading style sheets ppt.sildeshower phone view
cascading style sheets ppt.sildeshower phone view
kedaringle994
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
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
 
Lecture-6.pptx
Lecture-6.pptxLecture-6.pptx
Lecture-6.pptx
vishal choudhary
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
Web Design Course: CSS lecture 2
Web Design Course: CSS  lecture 2Web Design Course: CSS  lecture 2
Web Design Course: CSS lecture 2
Gheyath M. Othman
 
css-ppt.pdf
css-ppt.pdfcss-ppt.pdf
css-ppt.pdf
EktaDesai14
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
Programmer Blog
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
Rafi Haidari
 
Css introduction
Css introductionCss introduction
Css introduction
Sridhar P
 
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
 
properties of css.pptx power pointpresentation
properties of css.pptx power pointpresentationproperties of css.pptx power pointpresentation
properties of css.pptx power pointpresentation
Coderkids
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
cascading style sheets ppt.sildeshower phone view
cascading style sheets ppt.sildeshower phone viewcascading style sheets ppt.sildeshower phone view
cascading style sheets ppt.sildeshower phone view
kedaringle994
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptxUnitegergergegegegetgegegegegegeg-2-CSS.pptx
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
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
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
Web Design Course: CSS lecture 2
Web Design Course: CSS  lecture 2Web Design Course: CSS  lecture 2
Web Design Course: CSS lecture 2
Gheyath M. Othman
 
Ad

More from Folasade Adedeji (8)

Social media and the christian youth
Social media and the christian youthSocial media and the christian youth
Social media and the christian youth
Folasade Adedeji
 
Creating Interactive Lessons with PowerPoint and Office Mix
Creating Interactive Lessons with PowerPoint and Office MixCreating Interactive Lessons with PowerPoint and Office Mix
Creating Interactive Lessons with PowerPoint and Office Mix
Folasade Adedeji
 
Artificial Intelligence: How to prepare yourself for the future
Artificial Intelligence: How to prepare yourself for the futureArtificial Intelligence: How to prepare yourself for the future
Artificial Intelligence: How to prepare yourself for the future
Folasade Adedeji
 
ICT and MOOC for life long learning
ICT and MOOC for life long learningICT and MOOC for life long learning
ICT and MOOC for life long learning
Folasade Adedeji
 
Webinar presentation on cloud computing
Webinar presentation on cloud computingWebinar presentation on cloud computing
Webinar presentation on cloud computing
Folasade Adedeji
 
Moodle question types 01 - Calculated Questions
Moodle question types 01 - Calculated QuestionsMoodle question types 01 - Calculated Questions
Moodle question types 01 - Calculated Questions
Folasade Adedeji
 
Introduction to Html
Introduction to HtmlIntroduction to Html
Introduction to Html
Folasade Adedeji
 
Introduction to the internet
Introduction to the internetIntroduction to the internet
Introduction to the internet
Folasade Adedeji
 
Social media and the christian youth
Social media and the christian youthSocial media and the christian youth
Social media and the christian youth
Folasade Adedeji
 
Creating Interactive Lessons with PowerPoint and Office Mix
Creating Interactive Lessons with PowerPoint and Office MixCreating Interactive Lessons with PowerPoint and Office Mix
Creating Interactive Lessons with PowerPoint and Office Mix
Folasade Adedeji
 
Artificial Intelligence: How to prepare yourself for the future
Artificial Intelligence: How to prepare yourself for the futureArtificial Intelligence: How to prepare yourself for the future
Artificial Intelligence: How to prepare yourself for the future
Folasade Adedeji
 
ICT and MOOC for life long learning
ICT and MOOC for life long learningICT and MOOC for life long learning
ICT and MOOC for life long learning
Folasade Adedeji
 
Webinar presentation on cloud computing
Webinar presentation on cloud computingWebinar presentation on cloud computing
Webinar presentation on cloud computing
Folasade Adedeji
 
Moodle question types 01 - Calculated Questions
Moodle question types 01 - Calculated QuestionsMoodle question types 01 - Calculated Questions
Moodle question types 01 - Calculated Questions
Folasade Adedeji
 
Introduction to the internet
Introduction to the internetIntroduction to the internet
Introduction to the internet
Folasade Adedeji
 
Ad

Recently uploaded (20)

Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?
Amara Nielson
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEMGDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
philipnathen82
 
Full Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest VersionFull Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest Version
jonesmichealj2
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?
Amara Nielson
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEMGDS SYSTEM | GLOBAL  DISTRIBUTION SYSTEM
GDS SYSTEM | GLOBAL DISTRIBUTION SYSTEM
philipnathen82
 
Full Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest VersionFull Cracked Resolume Arena Latest Version
Full Cracked Resolume Arena Latest Version
jonesmichealj2
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 

Introduction to CSS

  • 1. WEB DESIGN TRAINING 03 INTRODUCTION TO CASCADING STYLE SHEETS(CSS) Presented by Folasade Adedeji
  • 2. Cascading Style Sheets  A key tool in web design  CSS is the sister technology to HTML that is used to style web pages.  CSS is used to control the style and layout of multiple Web pages all at once.  CSS defines HOW HTML elements are to be displayed.
  • 3. Cascading Style Sheets  Styles are normally saved in external .css files  External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!
  • 4. CSS Syntax  A CSS rule has two main parts: a selector, and one or more declarations:
  • 6. CSS Syntax  A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets:  p {color:red;text-align:center;} p { color:red; text-align:center; }
  • 7. CSS Comment  Comments are used to explain your code  Comments are ignored by browsers.  A CSS comment begins with "/*“  and ends with "*/", for example: /*This is a comment*/ p { text-align:center; /*This is another comment*/ color:black; font-family:arial; }
  • 8. CSS id and class  The id selector is used to specify a style for a single, unique element.  The id selector uses the id attribute of the HTML element, and is defined with a "#".  The style rule below will be applied to the element with id="para1": #para1 { text-align:center; color:red; }
  • 9. Class selector  The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements.  This allows you to set a particular style for many HTML elements with the same class.  The class selector uses the HTML class attribute, and is defined with a "."  In the example below, all HTML elements with class="center" will be center-aligned: Example .center {text-align:center;}
  • 10.  You can also specify that only specific HTML elements should be affected by a class.  In the example below, all p elements with class="center" will be center-aligned: Example p.center {text-align:center;}
  • 11. How to Insert CSS Three Ways to Insert CSS There are three ways of inserting a style sheet:  External style sheet  Internal style sheet  Inline style
  • 12. External Style Sheet  An external style sheet is used when the style is applied to many pages.  With an external style sheet, you can change the look of an entire Web site by changing one file.  Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section: <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head>
  • 13.  An external style sheet can be written in any text editor.  The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below: hr {color:sienna;} p {margin-left:20px;} body {background- image:url("images/background.gif");}
  • 14. Internal Style Sheet  An internal style sheet should be used when a single document has a unique style.  You define internal styles in the head section of an HTML page, by using the <style> tag, like this: <head> <style> hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/back.gif");} </style> </head>
  • 15. Inline Styles  To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph:  <p style="color:sienna;margin-left:20px;">This is a paragraph.</p>
  • 16. Multiple Style Sheets  If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet.
  • 17. Multiple Style Sheets For example, an external style sheet has these properties for the h3 selector: h3 { color:red; text-align:left; font-size:8pt; } And an internal style sheet has these properties for the h3 selector: h3 { text-align:right; font-size:20pt; } If the page with the internal style sheet also links to the external style sheet the properties for h3 will be: color:red; text-align:right; font-size:20pt; The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet.
  • 18. Cascading Order  What style will be used when there is more than one style specified for an HTML element?  Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority:  Browser default  External style sheet  Internal style sheet (in the head section)  Inline style (inside an HTML element)  So, an 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).
  • 19. CSS Background CSS background properties are used to define the background effects of an element. CSS properties used for background effects:  background-color  background-image  background-repeat  background-attachment  background-position
  • 20. Background Color  The background-color property specifies the background color of an element.  The background color of a page is defined in the body selector:  Example  body {background-color:#b0c4de;}
  • 21. <!DOCTYPE html> <html> <head> <style> h1 { background-color:#6495ed; } p { background-color:#e0ffff; } div { background-color:#b0c4de; } </style> </head> <body> <h1>CSS background-color example!</h1> <div> This is a text inside a div element. <p>This paragraph has its own background color.</p> We are still in the div element. </div> </body>
  • 22. Background Image  The background-image property specifies an image to use as the background of an element.  By default, the image is repeated so it covers the entire element.  The background image for a page can be set like this:  Example  body {background-image:url("paper.gif");}
  • 23. Background Image - Repeat Horizontally or Vertically  By default, the background-image property repeats an image both horizontally and vertically.  Some images should be repeated only horizontally or vertically, or they will look strange, like this:  Example  body { background-image:url(“back2.png"); }
  • 24.  If the image is repeated only horizontally (repeat-x), the background will look better:  Example  body { background-image:url(“back2.png"); background-repeat:repeat-x; }
  • 25. Background Image - Set position and no-repeat  Showing the image only once is specified by the background-repeat property:  Example  body { background-image:url(“me.png"); background-repeat:no-repeat; }
  • 26.  In the example above, the background image is shown in the same place as the text. We want to change the position of the image, so that it does not disturb the text too much.  The position of the image is specified by the background-position property:  Example  body { background-image:url(“me.png"); background-repeat:no-repeat; background-position:right top; }
  • 27. Background - Shorthand property  As you can see from the examples above, there are many properties to consider when dealing with backgrounds.  To shorten the code, it is also possible to specify all the properties in one single property. This is called a shorthand property.  The shorthand property for background is simply "background":  Example  body {background:#ffffff url(“me.png") no-repeat right top;}
  • 28.  To be continued