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
CSSCSS
CSS
venkatachalam84
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
WordPress Memphis
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
Amit Kumar Singh
 
CSS
CSSCSS
CSS
seedinteractive
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
vikasgaur31
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
Html ppt
Html pptHtml ppt
Html ppt
santosh lamba
 
Html coding
Html codingHtml coding
Html coding
Briana VanBuskirk
 
Html
HtmlHtml
Html
irshadahamed
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
Fahim Abdullah
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
Dave Kelly
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
Sanjeev Kumar
 
HTML
HTMLHTML
HTML
Akash Varaiya
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntax
priyadharshini murugan
 
Presentation on HTML
Presentation on HTMLPresentation on HTML
Presentation on HTML
satvirsandhu9
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
casestudyhelp
 
Css notes
Css notesCss notes
Css notes
Computer Hardware & Trouble shooting
 
Html ppt computer
Html ppt computerHtml ppt computer
Html ppt computer
Anmol Pant
 
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
 

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)

Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Adobe Media Encoder Crack FREE Download 2025
Adobe Media Encoder  Crack FREE Download 2025Adobe Media Encoder  Crack FREE Download 2025
Adobe Media Encoder Crack FREE Download 2025
zafranwaqar90
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
The Elixir Developer - All Things Open
The Elixir Developer - All Things OpenThe Elixir Developer - All Things Open
The Elixir Developer - All Things Open
Carlo Gilmar Padilla Santana
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Gojek Clone App for Multi-Service Business
Gojek Clone App for Multi-Service BusinessGojek Clone App for Multi-Service Business
Gojek Clone App for Multi-Service Business
XongoLab Technologies LLP
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
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
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Adobe Media Encoder Crack FREE Download 2025
Adobe Media Encoder  Crack FREE Download 2025Adobe Media Encoder  Crack FREE Download 2025
Adobe Media Encoder Crack FREE Download 2025
zafranwaqar90
 
AEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural MeetingAEM User Group DACH - 2025 Inaugural Meeting
AEM User Group DACH - 2025 Inaugural Meeting
jennaf3
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
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
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 

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
  翻译: