SlideShare a Scribd company logo
CSS
What is CSS?
• CSS stands for Cascading Style Sheets
• Styles define how to display HTML elements
• Styles are added to HTML 4.0
• External Style Sheets are stored in CSS files
Styles Solved a Big Problem
• HTML was never intended to contain tags for formatting a document
• When tags like <font>, and color attributes were added to the HTML
3.2 specification, it started a nightmare for web developers.
• To solve this problem, the World Wide Web Consortium (W3C)
created CSS.
• In HTML 4.0, all formatting could be removed from the HTML
document, and stored in a separate CSS file.
• All browsers support CSS today.
CSS Saves a Lot of Work!
• CSS defines HOW HTML elements are to be displayed
• 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:
• The selector is normally the HTML element you want to style.
• Each declaration consists of a property and a value.
• The property is the style attribute you want to change.
• Each property has a value.
CSS Selectors
• Three types of CSS Selectors
• Element
• Class
• ID
CSS Element Selector Example
• A CSS declaration always ends with a semicolon, and declaration
groups are surrounded by curly brackets:
• p {color:red;text-align:center;}
• To make the CSS more readable, you can put one declaration on each
line, like this:
• p { color:red;
text-align:center;
}
CSS Comments
• Are used to explain code, and may help to edit the source code at a
later
• Are ignored by browsers
• A CSS comment begins with "/*", and ends with "*/"
• p{
text-align:center;
/*This is another comment*/
color:black;
font-family:arial;
}
The id and class Selectors
• In addition to setting a style for a HTML element, CSS allows you to
specify our own selectors which are:
• Id
• Class
The id Selector
• 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 "#".
• Example
• Imagine within the body element of our html page, we have the following
paragraph element
<p id=”welcome”>Welcome to the wonderful world of HTML</p>
• We can then create a CSS rule with the id selector:
#welcome { text-align:center; color:red; }
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
"."
• Example:
• Imagine within the body element of our html page, we have the
following header element
<h2 class=”center”>Summary</h2>
• We can then create a CSS rule with the class selector:
.center {text-align:center;}
• 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;}
CSS Box Model
Three Ways to Insert CSS
• External style sheet
• Internal style sheet
• Inline style
External Style Sheet
• An external style sheet is ideal 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.
• 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.
• Example:
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
Inline Styles
• An inline style loses many of the advantages of style sheets by mixing
content with presentation.
• To use inline styles you use the style attribute in the relevant tag.
• The style attribute can contain any CSS property.
• Example:
• Multiple styles are cascaded in to one style.
• The order of priority is(first is of the least priority):
• Browser default
• External style sheet
• Internal style sheet (in the head section)
• Inline style (inside an HTML element)
CSS Background Properties
• background-color
• background-image
• background-repeat
CSS Border Properties
• border-style can have the following values:
• none: Defines no border
• dotted: Defines a dotted border
• dashed: Defines a dashed border
• solid: Defines a solid border
• border-width property is used to set the width of the border
• border-color property is used to set the color of the border.
• The color can be set by:
• name - specify a color name, like "red“
• RGB - specify a RGB value, like "rgb(255,0,0)“
• Hex - specify a hex value, like "#ff0000"
• color property is used to set the color of the text
• text-align property is used to set the horizontal alignment of a text
• text-decoration property is used to set or remove decorations from
text
• text-transform property is used to specify uppercase and lowercase
letters in a text
• Can be used to turn everything into uppercase or lowercase letters, or
capitalize the first letter of each word
• text-indent property is used to specify the indentation
Grouping Selectors
Nesting Selectors
What is CSS Float?
• With CSS float, an element can be pushed to the left or right, allowing
other elements to wrap around it
• Float is very often used for images, but it is also useful when working
with layouts
Turning off Float
Navigation Bars
• Having easy-to-use navigation is important for any web site
• With CSS you can transform boring HTML menus into good-looking
navigation bars
• Navigation Bar = List of Links
Css
Vertical Navigation Bar
height
Horizontal Navigation Bar
• There are two ways to create a horizontal navigation bar
• Using inline list items
• Using floating list items
• Both methods work fine, but if you want the links to be the same size,
you have to use the floating method.
Inline List Items
• One way to build a horizontal navigation bar is to specify the <li>
elements as inline, in addition to the "standard" code above
Floating List Items
• In the example above the links have different widths
• For all the links to have an equal width, float the <li> elements and
specify a width for the <a> elements

More Related Content

PPTX
PPTX
Unit iv xml dom
PPTX
Cascading style sheets
PPTX
Dom date and objects and event handling
PPTX
Introduction to XML
PPTX
Html (1)
PPT
Markup Languages
PDF
Basics and different xml files used in android
Unit iv xml dom
Cascading style sheets
Dom date and objects and event handling
Introduction to XML
Html (1)
Markup Languages
Basics and different xml files used in android

What's hot (19)

PDF
HTML and XML Difference FAQs
PPTX
Unit iv xml
PPTX
Publishing xml
PPT
Introduction to XML
PPT
XML for beginners
PPTX
Xml unit1
PPT
Introduction to XML
PPT
Xml Lecture Notes
PPTX
Web Development - Lecture 5
PPS
Xml basics for beginning
PPTX
Web Development - Lecture 4
PPTX
Basics of XML
PPTX
Web Development - Lecture 3
PPT
Introduction to XML
PPT
PPTX
Unit3wt
PPTX
uptu web technology unit 2 html
HTML and XML Difference FAQs
Unit iv xml
Publishing xml
Introduction to XML
XML for beginners
Xml unit1
Introduction to XML
Xml Lecture Notes
Web Development - Lecture 5
Xml basics for beginning
Web Development - Lecture 4
Basics of XML
Web Development - Lecture 3
Introduction to XML
Unit3wt
uptu web technology unit 2 html
Ad

Similar to Css (20)

PPTX
basic programming language AND HTML CSS JAVApdf
PPTX
UNIT 3WOP fgfufhbuiibpvihbvpihivbhibvipuuvbiuvboi
PPTX
BITM3730 9-19.pptx
PPTX
BITM3730 9-20.pptx
PPTX
Cascading style sheets
PPTX
cascadingstylesheets,introduction.css styles-210909054722.pptx
PPSX
CSS Comprehensive Overview
PPTX
BITM3730Week4.pptx
PPTX
CSS Basics part One
PPTX
CSS tutorial chapter 1
PPTX
Unit 2 WT-CSS.pptx web technology project
PPTX
WEB TECHNOLOGY Unit-2.pptx
PPTX
PPTX
CSS Introduction
PPTX
Introduction to Wed System And Technologies (1).pptx
PDF
PDF
Intro to html, css & sass
basic programming language AND HTML CSS JAVApdf
UNIT 3WOP fgfufhbuiibpvihbvpihivbhibvipuuvbiuvboi
BITM3730 9-19.pptx
BITM3730 9-20.pptx
Cascading style sheets
cascadingstylesheets,introduction.css styles-210909054722.pptx
CSS Comprehensive Overview
BITM3730Week4.pptx
CSS Basics part One
CSS tutorial chapter 1
Unit 2 WT-CSS.pptx web technology project
WEB TECHNOLOGY Unit-2.pptx
CSS Introduction
Introduction to Wed System And Technologies (1).pptx
Intro to html, css & sass
Ad

More from Kamal Acharya (20)

PPTX
Programming the basic computer
PPTX
Computer Arithmetic
PPTX
Introduction to Computer Security
PPTX
Session and Cookies
PPTX
Functions in php
PPTX
Web forms in php
PPTX
Making decision and repeating in PHP
PPTX
Working with arrays in php
PPTX
Text and Numbers (Data Types)in PHP
PPTX
Introduction to PHP
PPTX
Capacity Planning of Data Warehousing
PPTX
Data Warehousing
PPTX
Search Engines
PPTX
Web Mining
PPTX
Information Privacy and Data Mining
PPTX
Cluster Analysis
PPTX
Association Analysis in Data Mining
PPTX
Classification techniques in data mining
PPTX
Data Preprocessing
PPTX
Introduction to Data Mining and Data Warehousing
Programming the basic computer
Computer Arithmetic
Introduction to Computer Security
Session and Cookies
Functions in php
Web forms in php
Making decision and repeating in PHP
Working with arrays in php
Text and Numbers (Data Types)in PHP
Introduction to PHP
Capacity Planning of Data Warehousing
Data Warehousing
Search Engines
Web Mining
Information Privacy and Data Mining
Cluster Analysis
Association Analysis in Data Mining
Classification techniques in data mining
Data Preprocessing
Introduction to Data Mining and Data Warehousing

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Microbial diseases, their pathogenesis and prophylaxis
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
VCE English Exam - Section C Student Revision Booklet
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Renaissance Architecture: A Journey from Faith to Humanism
102 student loan defaulters named and shamed – Is someone you know on the list?
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Cell Structure & Organelles in detailed.
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Complications of Minimal Access Surgery at WLH
STATICS OF THE RIGID BODIES Hibbelers.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Microbial disease of the cardiovascular and lymphatic systems
Supply Chain Operations Speaking Notes -ICLT Program
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Module 4: Burden of Disease Tutorial Slides S2 2025
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx

Css

  • 1. CSS
  • 2. What is CSS? • CSS stands for Cascading Style Sheets • Styles define how to display HTML elements • Styles are added to HTML 4.0 • External Style Sheets are stored in CSS files
  • 3. Styles Solved a Big Problem • HTML was never intended to contain tags for formatting a document • When tags like <font>, and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. • To solve this problem, the World Wide Web Consortium (W3C) created CSS. • In HTML 4.0, all formatting could be removed from the HTML document, and stored in a separate CSS file. • All browsers support CSS today.
  • 4. CSS Saves a Lot of Work! • CSS defines HOW HTML elements are to be displayed • 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!
  • 5. CSS Syntax • A CSS rule has two main parts: a selector, and one or more declarations: • The selector is normally the HTML element you want to style. • Each declaration consists of a property and a value. • The property is the style attribute you want to change. • Each property has a value.
  • 6. CSS Selectors • Three types of CSS Selectors • Element • Class • ID
  • 7. CSS Element Selector Example • A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets: • p {color:red;text-align:center;} • To make the CSS more readable, you can put one declaration on each line, like this: • p { color:red; text-align:center; }
  • 8. CSS Comments • Are used to explain code, and may help to edit the source code at a later • Are ignored by browsers • A CSS comment begins with "/*", and ends with "*/" • p{ text-align:center; /*This is another comment*/ color:black; font-family:arial; }
  • 9. The id and class Selectors • In addition to setting a style for a HTML element, CSS allows you to specify our own selectors which are: • Id • Class
  • 10. The id Selector • 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 "#". • Example • Imagine within the body element of our html page, we have the following paragraph element <p id=”welcome”>Welcome to the wonderful world of HTML</p> • We can then create a CSS rule with the id selector: #welcome { text-align:center; color:red; }
  • 11. 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 "."
  • 12. • Example: • Imagine within the body element of our html page, we have the following header element <h2 class=”center”>Summary</h2> • We can then create a CSS rule with the class selector: .center {text-align:center;}
  • 13. • 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;}
  • 15. Three Ways to Insert CSS • External style sheet • Internal style sheet • Inline style
  • 16. External Style Sheet • An external style sheet is ideal 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.
  • 17. • 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. • Example:
  • 18. 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
  • 19. Inline Styles • An inline style loses many of the advantages of style sheets by mixing content with presentation. • To use inline styles you use the style attribute in the relevant tag. • The style attribute can contain any CSS property. • Example:
  • 20. • Multiple styles are cascaded in to one style. • The order of priority is(first is of the least priority): • Browser default • External style sheet • Internal style sheet (in the head section) • Inline style (inside an HTML element)
  • 21. CSS Background Properties • background-color • background-image • background-repeat
  • 22. CSS Border Properties • border-style can have the following values: • none: Defines no border • dotted: Defines a dotted border • dashed: Defines a dashed border • solid: Defines a solid border
  • 23. • border-width property is used to set the width of the border
  • 24. • border-color property is used to set the color of the border. • The color can be set by: • name - specify a color name, like "red“ • RGB - specify a RGB value, like "rgb(255,0,0)“ • Hex - specify a hex value, like "#ff0000"
  • 25. • color property is used to set the color of the text
  • 26. • text-align property is used to set the horizontal alignment of a text
  • 27. • text-decoration property is used to set or remove decorations from text
  • 28. • text-transform property is used to specify uppercase and lowercase letters in a text • Can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word
  • 29. • text-indent property is used to specify the indentation
  • 32. What is CSS Float? • With CSS float, an element can be pushed to the left or right, allowing other elements to wrap around it • Float is very often used for images, but it is also useful when working with layouts
  • 34. Navigation Bars • Having easy-to-use navigation is important for any web site • With CSS you can transform boring HTML menus into good-looking navigation bars • Navigation Bar = List of Links
  • 37. Horizontal Navigation Bar • There are two ways to create a horizontal navigation bar • Using inline list items • Using floating list items • Both methods work fine, but if you want the links to be the same size, you have to use the floating method.
  • 38. Inline List Items • One way to build a horizontal navigation bar is to specify the <li> elements as inline, in addition to the "standard" code above
  • 39. Floating List Items • In the example above the links have different widths • For all the links to have an equal width, float the <li> elements and specify a width for the <a> elements