SlideShare a Scribd company logo
Intro to CSS
What is CSS?
• CSS stands for Cascading Style Sheets
• A specification for the presentation of HTML documents.
Like a template; used to define a style for an HTML
element and then applied across one or more Web pages.
• Provides the ability to separate the layout and styles of a
web page from the data or information. Styles such as
fonts, font sizes, letter spacing, colors, borders, and
margins, can be specified in one place.
Old-School Example
<html>
<head>
<title>Old School</title>
</head>
<body>
<font face=arial size=6>Example Head</font><br>
<p><font size=4>Main text here.</font></p>
<font face=arial size=6>Another Head</font><br>
<p><font size=4>More text here.</font></p>
</body>
</html>
Traditional Markup vs. CSS
Traditional
HTML mixes
presentation
with data
CSS
separates
content from
presentation,
making it
much easier
to manage
both data and
design!
Why CSS?
• Imagine you manage a site with 100+ pages. The boss
wants you to change the font of all headings, which appear
an average of five places per page. Once you’ve done it,
he changes his mind. Now imagine the site has 10,000
pages.
• CSS lets us change a single entry to make immediate
changes.
Cascading?
• Cascading means that the style definitions flow
down into the nested tags.
– Ex. Applying the color red to the <body> element will
cascade down through other elements like <p>
How is CSS implemented?
• CSS can be written for different media (screen, printer,
etc), can be included in an HTML document, or can be a
separate file that is applied to multiple HTML documents.
• Styles can be external, internal, or inline.
– What are the benefits of a separate file vs.
internal/inline?
• We will focus on external style sheets
• Inline style has the highest priority and will override all others
• The style applies only to the HTML element in which it is declared
Internal styles
• They are placed in the <HEAD> section and apply to all elements of a
certain type
• <HEAD>
• <STYLE type = “text/css”>
• H1 {color: blue; font-size: 20pt}
• H2 {color: red; font-family: Arial, sans-serif}
• </STYLE>
• The above CSS – “rules” are applied to all H1 and H2 elements in the
document
Implementing CSS
• First step, write good, well-formed HTML without modifiers.
Use only generic tags like <h1>, <p>, etc.
• Inside the <head> section, add:
<link href="file.css" rel="stylesheet" type="text/css" />
• Create a text file (named with a .css extension)
• Populate the new CSS file with CSS selectors and styles!
Parts of the CSS File
h1 {
color: blue
font-size: 18px;
}
Selector Properties
•The selector is defined by the style (made up of properties).
•All content wrapped in <h1> tags throughout the pages
where the CSS file is linked will be blue and 18 pixels tall.
Style
Basic Syntax
• Selector: Can be any HTML element. The Selector
is simply the tag element linked to a style.
– Example
p { color:red; }
‘p’ is the selector. All text wrapped with the <p> tag will be
colored red
Example CSS file
body{
padding:0px;
margin:0px;
background-color:#FFE8C6;
font-size: 12px;
}
p {
font-family: Tahoma, Helvetica;
color: red;
}
h1 {
font-family: Tahoma, Helvetica;
font-size: 24px;
}
Defines the <body> tag
Defines the <p> tag
Defines the <h1> tag
New-School: Before CSS
<html>
<head>
<title>New School</title>
</head>
<body>
<h1>Example Head</h1>
<p>Main text here.</p>
<h1>Another Head</h1>
<p>More text here.</p>
</body>
</html>
Note the change from
<font> tags in the Old-
School example to the
<h1> tags, as well as
the elimination of the
<font> tags that were
nested inside the <p>
tags.
New-School: With CSS
<html>
<head>
<title>New School with CSS</title>
<link href="style.css" rel="stylesheet"
type="text/css" />
</head>
<body>
<h1>Example Head</h1>
<p>Main text here.</p>
<h1>Another Head</h1>
<p>More text here.</p>
</body>
</html>
Note the addition of the
<link> tag, which links in
our style sheet.
Selectors: Classes
• We can create classes, which are a named subset
of a tag.
p {
font-family: Tahoma, Helvetica;
color: red;
}
p.quote {
font-family: Tahoma, Helvetica;
color: green;
}
Defines the <p> tag
Defines a class of
the <p> tag called
quote.
Selectors: Classes
• A Class selector can be created without a tag,
making it available to any element.
.corrected {
font-style: italic;
text-transform: capitalize;
color: #666699;
text-decoration: line-through;
}
Defines a class of
the <p> tag called
corrected.
Selectors: ID
• An ID selector is intended for single-use.
• Should be used sparingly, since it defines a single
instance of “something”.
#X57 {
letter-spacing: 0.3em
}
Increases letter
spacing for an
element that uses
the id=X57 attribute
Selectors: Contextual
• Contextual selectors are made up of two or more selectors
separated by white space.
• They take precedence over simple selectors.
• This contextual selector draws <em> text in a <p> with a
yellow background; <em> text elsewhere would be
unaffected.
p em {
background: yellow;
}
Selectors: Pseudo Classes
• Define the state of certain selectors, such as the <a> tag’s link,
hover, visited and active states.
a:link {
color: black;
}
a:hover {
color: blue;
font-size: 125%;
}
a:visited {
color: green;
font-weight: bold;
}
Defines the link state
of the <a> tag
Defines the visited
state of the <a> tag
Defines the hover
state of the <a> tag
Selectors: Pseudo Elements
Special capabilities of the <p> selector:
p:first-line {
font-variant: small-caps;
}
p:first-letter {
font-size: 300%;
float: left
}
First line of <p> will be
in small caps
First letter of <p> will
be large
Comments
• Comments are valuable in CSS files too!
/* This is a comment */
• CLASSES
• Class declarations are preceded by a period and apply to all elements of the class:
• <STYLE>
• .highlight {color: red; font-style: italic}
• </STYLE>
• <BODY>
• <P class= “highlight”>……..</P>
•
• ELEMENTS
• Elements are declared starting with # and are applied to only one element referenced by an ID
•
• NB:
• Two types of paragraphs in your document:
• One is right aligned paragraph
• The other is center aligned paragraph
• How to do it with styles?
• Solution: Use class selector
• <STYLE>
• p.right {text-align: right}
• Class
• Tag/element name which is optional
• <p.center { text-align: center}
• </STYLE>
• Now use the class attribute in your HTML document as:
• <p class = “right”>
• Right aligned paragraph
• <p class = “center”>
• Center aligned paragraph
• </p>
•
• NB: Only one class can be specified per HTML document
• <STYLE>
• #name {text aligned: center}
• </STYLE>
• <BODY>
• <H1 ID = “name”>
Resources
• Training: http://www.w3schools.com/css/
• W3C: http://www.w3.org/Style/CSS/
• http://www.w3schools.com/css/css_reference.asp

More Related Content

PPT
Unit 2-CSS & Bootstrap.ppt
PPTX
Web Development - Lecture 5
PPT
PPTX
Ifi7174 lesson2
PPTX
cascading style sheets- About cascading style sheets on the selectors
PDF
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
PPTX
Lecture-6.pptx
PPT
CSS Training in Bangalore
Unit 2-CSS & Bootstrap.ppt
Web Development - Lecture 5
Ifi7174 lesson2
cascading style sheets- About cascading style sheets on the selectors
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Lecture-6.pptx
CSS Training in Bangalore

Similar to Learning CSS for beginners.ppt all that are but (20)

PPTX
Cascading Style Sheets for web browser.pptx
PPTX
Cascading style sheet, CSS Box model, Table in CSS
PPTX
Lecture 3CSS part 1.pptx
PPT
IP - Lecture 6, 7 Chapter-3 (3).ppt
PDF
Introduction to css
PPTX
chitra
PPTX
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
PDF
4. Web Technology CSS Basics-1
PPT
Cascading Style Sheet
PDF
Intro to HTML and CSS - Class 2 Slides
PDF
Cascading Style Sheets
PPT
Make Css easy(part:2) : easy tips for css(part:2)
PPTX
Introduction to CSS.pptx web for web web
PPT
CSS-part-1.ppt
PPTX
What is CSS.pptx power point presentation
PPT
Lecture 5 _ Introduction to CSS-1.ppt. Cascading Style Sheet
PPT
Make Css easy : easy tips for css
PDF
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
Cascading Style Sheets for web browser.pptx
Cascading style sheet, CSS Box model, Table in CSS
Lecture 3CSS part 1.pptx
IP - Lecture 6, 7 Chapter-3 (3).ppt
Introduction to css
chitra
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
4. Web Technology CSS Basics-1
Cascading Style Sheet
Intro to HTML and CSS - Class 2 Slides
Cascading Style Sheets
Make Css easy(part:2) : easy tips for css(part:2)
Introduction to CSS.pptx web for web web
CSS-part-1.ppt
What is CSS.pptx power point presentation
Lecture 5 _ Introduction to CSS-1.ppt. Cascading Style Sheet
Make Css easy : easy tips for css
cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf
Ad

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
A Presentation on Artificial Intelligence
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
KodekX | Application Modernization Development
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Monthly Chronicles - July 2025
Advanced methodologies resolving dimensionality complications for autism neur...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
A Presentation on Artificial Intelligence
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
KodekX | Application Modernization Development
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Ad

Learning CSS for beginners.ppt all that are but

  • 2. What is CSS? • CSS stands for Cascading Style Sheets • A specification for the presentation of HTML documents. Like a template; used to define a style for an HTML element and then applied across one or more Web pages. • Provides the ability to separate the layout and styles of a web page from the data or information. Styles such as fonts, font sizes, letter spacing, colors, borders, and margins, can be specified in one place.
  • 3. Old-School Example <html> <head> <title>Old School</title> </head> <body> <font face=arial size=6>Example Head</font><br> <p><font size=4>Main text here.</font></p> <font face=arial size=6>Another Head</font><br> <p><font size=4>More text here.</font></p> </body> </html>
  • 4. Traditional Markup vs. CSS Traditional HTML mixes presentation with data CSS separates content from presentation, making it much easier to manage both data and design!
  • 5. Why CSS? • Imagine you manage a site with 100+ pages. The boss wants you to change the font of all headings, which appear an average of five places per page. Once you’ve done it, he changes his mind. Now imagine the site has 10,000 pages. • CSS lets us change a single entry to make immediate changes.
  • 6. Cascading? • Cascading means that the style definitions flow down into the nested tags. – Ex. Applying the color red to the <body> element will cascade down through other elements like <p>
  • 7. How is CSS implemented? • CSS can be written for different media (screen, printer, etc), can be included in an HTML document, or can be a separate file that is applied to multiple HTML documents. • Styles can be external, internal, or inline. – What are the benefits of a separate file vs. internal/inline? • We will focus on external style sheets
  • 8. • Inline style has the highest priority and will override all others • The style applies only to the HTML element in which it is declared
  • 9. Internal styles • They are placed in the <HEAD> section and apply to all elements of a certain type • <HEAD> • <STYLE type = “text/css”> • H1 {color: blue; font-size: 20pt} • H2 {color: red; font-family: Arial, sans-serif} • </STYLE> • The above CSS – “rules” are applied to all H1 and H2 elements in the document
  • 10. Implementing CSS • First step, write good, well-formed HTML without modifiers. Use only generic tags like <h1>, <p>, etc. • Inside the <head> section, add: <link href="file.css" rel="stylesheet" type="text/css" /> • Create a text file (named with a .css extension) • Populate the new CSS file with CSS selectors and styles!
  • 11. Parts of the CSS File h1 { color: blue font-size: 18px; } Selector Properties •The selector is defined by the style (made up of properties). •All content wrapped in <h1> tags throughout the pages where the CSS file is linked will be blue and 18 pixels tall. Style
  • 12. Basic Syntax • Selector: Can be any HTML element. The Selector is simply the tag element linked to a style. – Example p { color:red; } ‘p’ is the selector. All text wrapped with the <p> tag will be colored red
  • 13. Example CSS file body{ padding:0px; margin:0px; background-color:#FFE8C6; font-size: 12px; } p { font-family: Tahoma, Helvetica; color: red; } h1 { font-family: Tahoma, Helvetica; font-size: 24px; } Defines the <body> tag Defines the <p> tag Defines the <h1> tag
  • 14. New-School: Before CSS <html> <head> <title>New School</title> </head> <body> <h1>Example Head</h1> <p>Main text here.</p> <h1>Another Head</h1> <p>More text here.</p> </body> </html> Note the change from <font> tags in the Old- School example to the <h1> tags, as well as the elimination of the <font> tags that were nested inside the <p> tags.
  • 15. New-School: With CSS <html> <head> <title>New School with CSS</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>Example Head</h1> <p>Main text here.</p> <h1>Another Head</h1> <p>More text here.</p> </body> </html> Note the addition of the <link> tag, which links in our style sheet.
  • 16. Selectors: Classes • We can create classes, which are a named subset of a tag. p { font-family: Tahoma, Helvetica; color: red; } p.quote { font-family: Tahoma, Helvetica; color: green; } Defines the <p> tag Defines a class of the <p> tag called quote.
  • 17. Selectors: Classes • A Class selector can be created without a tag, making it available to any element. .corrected { font-style: italic; text-transform: capitalize; color: #666699; text-decoration: line-through; } Defines a class of the <p> tag called corrected.
  • 18. Selectors: ID • An ID selector is intended for single-use. • Should be used sparingly, since it defines a single instance of “something”. #X57 { letter-spacing: 0.3em } Increases letter spacing for an element that uses the id=X57 attribute
  • 19. Selectors: Contextual • Contextual selectors are made up of two or more selectors separated by white space. • They take precedence over simple selectors. • This contextual selector draws <em> text in a <p> with a yellow background; <em> text elsewhere would be unaffected. p em { background: yellow; }
  • 20. Selectors: Pseudo Classes • Define the state of certain selectors, such as the <a> tag’s link, hover, visited and active states. a:link { color: black; } a:hover { color: blue; font-size: 125%; } a:visited { color: green; font-weight: bold; } Defines the link state of the <a> tag Defines the visited state of the <a> tag Defines the hover state of the <a> tag
  • 21. Selectors: Pseudo Elements Special capabilities of the <p> selector: p:first-line { font-variant: small-caps; } p:first-letter { font-size: 300%; float: left } First line of <p> will be in small caps First letter of <p> will be large
  • 22. Comments • Comments are valuable in CSS files too! /* This is a comment */
  • 23. • CLASSES • Class declarations are preceded by a period and apply to all elements of the class: • <STYLE> • .highlight {color: red; font-style: italic} • </STYLE> • <BODY> • <P class= “highlight”>……..</P> • • ELEMENTS • Elements are declared starting with # and are applied to only one element referenced by an ID •
  • 24. • NB: • Two types of paragraphs in your document: • One is right aligned paragraph • The other is center aligned paragraph • How to do it with styles? • Solution: Use class selector • <STYLE> • p.right {text-align: right} • Class • Tag/element name which is optional • <p.center { text-align: center} • </STYLE> • Now use the class attribute in your HTML document as: • <p class = “right”> • Right aligned paragraph • <p class = “center”> • Center aligned paragraph • </p> • • NB: Only one class can be specified per HTML document • <STYLE> • #name {text aligned: center} • </STYLE> • <BODY> • <H1 ID = “name”>
  • 25. Resources • Training: http://www.w3schools.com/css/ • W3C: http://www.w3.org/Style/CSS/ • http://www.w3schools.com/css/css_reference.asp