SlideShare a Scribd company logo
Cascading Style Sheets (CSS) Atul Kahate [email_address]
CSS Basics CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles were added to HTML 4.0 to solve a problem  External Style Sheets can save you a lot of work  External Style Sheets are stored in CSS files  Multiple style definitions will cascade into one
Need for CSS – 1 HTML tags were originally designed to define the contents of a document They were supposed to say &quot;This is a header&quot;, &quot;This is a paragraph&quot;, &quot;This is a table&quot;, by using tags like <h1>, <p>, <table>, and so on The layout of the document was supposed to be taken care of by the browser, without using any formatting tags
Need for CSS – 2 The two major browsers - Netscape and Internet Explorer - continued to add new HTML tags and attributes (like the <font> tag and the color attribute) to the original HTML specification It became more and more difficult to create Web sites where the content of HTML documents was clearly separated from the document's presentation layout
Need for CSS – 3 To solve this problem, the World Wide Web Consortium (W3C) - the non profit, standard setting consortium responsible for standardizing HTML - created styles in addition to HTML 4.0
What Can Styles Do? Define how HTML elements are displayed, just like the font tag and the color attribute in HTML 3.2 Normally saved in files external to your HTML documents External style sheets enable you to change the appearance and layout of all your pages, just by editing a single CSS document
Benefit to Developers Allows developers to control the style and layout of multiple Web pages all at once As a Web developer you can define a style for each HTML element and apply it to as many Web pages as you want To make a global change, simply change the style, and all elements in the Web site are updated automatically
Precedence in Style Sheets What style will be used when there is more than one style specified for an HTML element? The order is: Inline Style (inside HTML element) Internal Style Sheet (inside the <head> tag) External Style Sheet Browser default
CSS Syntax Consists of three parts selector {property: value} Selector: The HTML element/tag you wish to define Property: The attribute you wish to change Value: Associated with a property  The property and value are separated by a colon and surrounded by curly braces Examples body {color: black} p {font-family: &quot;sans serif&quot;} p {text-align:center;color:red}
<STYLE> P {color:green} P.red {color:red} </STYLE> Style block Selector Declaration Class
Better syntax for multiple properties p { text-align: center; color: black; font-family: arial }
Grouping Selectors h1,h2,h3,h4,h5,h6  { color: green }
Class Selector With the class selector you can define different styles for the same type of HTML element Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one center-aligned paragraph Example code follows
Class Selector Example CSS code p.right {text-align: right} p.center {text-align: center} HTML code <p class=&quot;right&quot;> This paragraph will be right-aligned. </p> <p class=&quot;center&quot;> This paragraph will be center-aligned. </p>
Comments in CSS /* This is a comment */
More on Font Families – 1 A font family contains a set of fonts that share common characteristics There are five font families Sans-serif Serif Serif Monospace Cursive Fantasy
More on Font Families – 2 Sans-serif – Considered to be readable Verdana ,  Arial Black ,  Trebuchet MS ,  Arial Serif – Similar to newspaper fonts Times New Roman ,  Georgia Monospace – Have constant width characters Courier New ,  Agency FB Cursive – Look like handwritten text Comic Sans ,  Harrington Fantasy – Decorative styles Impact
Style Sheet Example – 1 <html> <head> <style type=&quot;text/css&quot;> h1 {color: #00ff00} h2 {color: #dda0dd} p {color: rgb(0,0,255)} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
Style Sheet Example – 2 <html> <head> <style type=&quot;text/css&quot;> h1 {text-align: center} h2 {text-align: left} h3 {text-align: right} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <h3>This is header 3</h3> </body> </html>
Style Sheet Example – 3 <html> <head> <style type=&quot;text/css&quot;> h1 {text-decoration: overline} h2 {text-decoration: line-through} h3 {text-decoration: underline} a {text-decoration: none} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <h3>This is header 3</h3> <p> <a href=&quot;http://www.w3schools.com/default.asp&quot;> This is a link</a> </p> </body> </html>
Style Sheet Example – 4 <html> <head> <style type=&quot;text/css&quot;> p.uppercase {text-transform: uppercase} p.lowercase {text-transform: lowercase} p.capitalize {text-transform: capitalize} </style> </head> <body> <p class=&quot;uppercase&quot;> This is some text in a paragraph </p> <p class=&quot;lowercase&quot;> This is some text in a paragraph </p> <p class=&quot;capitalize&quot;> This is some text in a paragraph </p> </body> </html>
Style Sheet Example – 5 <html> <head> <style type=&quot;text/css&quot;> body {background-color: yellow} h1 {background-color: #00ff00} h2 {background-color: transparent} p {background-color: rgb(250,0,255)} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
Style Sheet Example – 6 <html> <head> <style type=&quot;text/css&quot;> h3 {font-family: times} p {font-family: courier} p.sansserif {font-family: sans-serif} </style> </head> <body> <h3>This is header 3</h3> <p> This is a paragraph</p> <p class=&quot;sansserif&quot;> This is a paragraph</p> </body> </html>
Style Sheet Example – 7 <html> <head> <style type=&quot;text/css&quot;> h1 {font-size: 150%} h2 {font-size: 130%} p {font-size: 100%} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
Style Sheet Example – 8 <html> <head> <style type=&quot;text/css&quot;> p.normal {font-weight: normal} p.thick {font-weight: bold} p.thicker {font-weight: 900} </style> </head> <body> <p class=&quot;normal&quot;> This is a paragraph</p> <p class=&quot;thick&quot;> This is a paragraph</p> <p class=&quot;thicker&quot;> This is a paragraph</p> </body> </html>
Style Sheet Example – 9 <html> <head> <style type=&quot;text/css&quot;> p.dotted {border-style: dotted} p.dashed {border-style: dashed} p.solid {border-style: solid} p.double {border-style: double} p.groove {border-style: groove} p.ridge {border-style: ridge} p.inset {border-style: inset} p.outset {border-style: outset} </style> </head> …
Style Sheet Example – 10 <html> <head> <style type=&quot;text/css&quot;> h1, h2 { font-family: sans-serif; color: gray; border-bottom: 1px solid black } p { color: maroon; } </style> </head> <body> <h1> Welcome to my Page! </h1> <H2> How are you doing? </h2> <p>This is a paragraph</p> </body> </html>
Style Sheet Example – 11 info.css h1, h2 { font-family: sans-serif; color: gray; } h1 { border-bottom: 1px solid black; } p { color: maroon; } main.html <html> <head> <title> External CSS Example </title> <link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;info.css&quot;> </head> <body> <h1> Welcome to my Page! </h1> <h2> How are you doing? </h2> <p>This is a paragraph</p> </body> </html>
Style Sheet Example – 12 info.css .test { line-height: 1.9em; font-style: italic; font-family: Georgia, &quot;Times New Roman&quot;, Times, serif; color: #444444; border-color: black; border-width: 1px; border-style: solid; background-color: #a7cece; padding: 25px; margin: 30px; } main.html <html> <head> <title> External CSS Example </title> <link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;info.css&quot;> </head> <body> <h1> Welcome to my Page! </h1> <h2> How are you doing? </h2> <p class=&quot;test&quot;> This is a paragraph. See how this is decorated with the help of styles. We have all sorts of paragraph and background formattng features available, which allow us to format text the way we want to a very precise level. </p> </body> </html>
Lists <html> <head> <style type=&quot;text/css&quot;> ul.disc  { list-style-type: disc } ul.circle  { list-style-type: circle } ul.square  { list-style-type: square } …
Thank you! Questions and Comments Welcome!

More Related Content

PPT
PPT
Html project
PPT
Html tag
PPTX
Html1
ODP
PPT
Html ppt
PPT
Html ppt
Html project
Html tag
Html1
Html ppt
Html ppt

What's hot (20)

PPT
Html Ppt
PPSX
Html introduction
PPTX
Introduction to html
PPT
Introduction To HTML
PDF
LAMP_TRAINING_SESSION_3
PPT
Introduction to html
PPT
HTML & CSS
PPTX
HTML (Web) basics for a beginner
PDF
Basic Html Notes
PPTX
Getting into HTML
ODP
CSS Basics
PPT
Html ppt computer
ODP
Html intro
PPTX
Lecture 2 introduction to html
PPT
Html Ppt
PPTX
Html Ppt
Html introduction
Introduction to html
Introduction To HTML
LAMP_TRAINING_SESSION_3
Introduction to html
HTML & CSS
HTML (Web) basics for a beginner
Basic Html Notes
Getting into HTML
CSS Basics
Html ppt computer
Html intro
Lecture 2 introduction to html
Html Ppt
Ad

Viewers also liked (13)

PPT
1 introduction to xml
DOC
Spring.pdf
PDF
PPT
3 xml namespaces and xml schema
PPT
5 xsl (formatting xml documents)
PPT
5 xml parsing
PPT
6 xml parsing
PPT
4 xml namespaces and xml schema
PPT
2 dtd - validating xml documents
PPT
Java script final presentation
PPTX
Java script
PPT
Java script
PPTX
HTML, CSS and Java Scripts Basics
1 introduction to xml
Spring.pdf
3 xml namespaces and xml schema
5 xsl (formatting xml documents)
5 xml parsing
6 xml parsing
4 xml namespaces and xml schema
2 dtd - validating xml documents
Java script final presentation
Java script
Java script
HTML, CSS and Java Scripts Basics
Ad

Similar to AK css (20)

PPS
PPTX
Design Dream
PPT
Block2 Session2 Presentation
PPT
IPW 3rd Course - CSS
ODP
Html intro
PPT
Html Expression Web
PPTX
Css intro
PPT
Cascading Style Sheets
PDF
Introduction to css
ODP
ODP
PPTX
1 03 - CSS Introduction
PPT
Diva
PPT
cascading style sheet ppt
PPTX
Html, CSS & Web Designing
Design Dream
Block2 Session2 Presentation
IPW 3rd Course - CSS
Html intro
Html Expression Web
Css intro
Cascading Style Sheets
Introduction to css
1 03 - CSS Introduction
Diva
cascading style sheet ppt
Html, CSS & Web Designing

More from gauravashq (9)

PDF
Spring
PDF
Spring
PDF
Spring
PPT
4 xslt
PPT
1 electronic data interchange (edi)
PDF
AK 5 JSF 21 july 2008
PDF
AK 4 JSF
PPT
AK 3 web services using apache axis
PPT
AK html
Spring
Spring
Spring
4 xslt
1 electronic data interchange (edi)
AK 5 JSF 21 july 2008
AK 4 JSF
AK 3 web services using apache axis
AK html

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Classroom Observation Tools for Teachers
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Pre independence Education in Inndia.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Basic Mud Logging Guide for educational purpose
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
Microbial diseases, their pathogenesis and prophylaxis
Classroom Observation Tools for Teachers
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Computing-Curriculum for Schools in Ghana
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
TR - Agricultural Crops Production NC III.pdf
Institutional Correction lecture only . . .
Pre independence Education in Inndia.pdf
RMMM.pdf make it easy to upload and study
Module 4: Burden of Disease Tutorial Slides S2 2025
Basic Mud Logging Guide for educational purpose
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Anesthesia in Laparoscopic Surgery in India
O7-L3 Supply Chain Operations - ICLT Program
Insiders guide to clinical Medicine.pdf

AK css

  • 1. Cascading Style Sheets (CSS) Atul Kahate [email_address]
  • 2. CSS Basics CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles are normally stored in Style Sheets Styles were added to HTML 4.0 to solve a problem External Style Sheets can save you a lot of work External Style Sheets are stored in CSS files Multiple style definitions will cascade into one
  • 3. Need for CSS – 1 HTML tags were originally designed to define the contents of a document They were supposed to say &quot;This is a header&quot;, &quot;This is a paragraph&quot;, &quot;This is a table&quot;, by using tags like <h1>, <p>, <table>, and so on The layout of the document was supposed to be taken care of by the browser, without using any formatting tags
  • 4. Need for CSS – 2 The two major browsers - Netscape and Internet Explorer - continued to add new HTML tags and attributes (like the <font> tag and the color attribute) to the original HTML specification It became more and more difficult to create Web sites where the content of HTML documents was clearly separated from the document's presentation layout
  • 5. Need for CSS – 3 To solve this problem, the World Wide Web Consortium (W3C) - the non profit, standard setting consortium responsible for standardizing HTML - created styles in addition to HTML 4.0
  • 6. What Can Styles Do? Define how HTML elements are displayed, just like the font tag and the color attribute in HTML 3.2 Normally saved in files external to your HTML documents External style sheets enable you to change the appearance and layout of all your pages, just by editing a single CSS document
  • 7. Benefit to Developers Allows developers to control the style and layout of multiple Web pages all at once As a Web developer you can define a style for each HTML element and apply it to as many Web pages as you want To make a global change, simply change the style, and all elements in the Web site are updated automatically
  • 8. Precedence in Style Sheets What style will be used when there is more than one style specified for an HTML element? The order is: Inline Style (inside HTML element) Internal Style Sheet (inside the <head> tag) External Style Sheet Browser default
  • 9. CSS Syntax Consists of three parts selector {property: value} Selector: The HTML element/tag you wish to define Property: The attribute you wish to change Value: Associated with a property The property and value are separated by a colon and surrounded by curly braces Examples body {color: black} p {font-family: &quot;sans serif&quot;} p {text-align:center;color:red}
  • 10. <STYLE> P {color:green} P.red {color:red} </STYLE> Style block Selector Declaration Class
  • 11. Better syntax for multiple properties p { text-align: center; color: black; font-family: arial }
  • 13. Class Selector With the class selector you can define different styles for the same type of HTML element Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one center-aligned paragraph Example code follows
  • 14. Class Selector Example CSS code p.right {text-align: right} p.center {text-align: center} HTML code <p class=&quot;right&quot;> This paragraph will be right-aligned. </p> <p class=&quot;center&quot;> This paragraph will be center-aligned. </p>
  • 15. Comments in CSS /* This is a comment */
  • 16. More on Font Families – 1 A font family contains a set of fonts that share common characteristics There are five font families Sans-serif Serif Serif Monospace Cursive Fantasy
  • 17. More on Font Families – 2 Sans-serif – Considered to be readable Verdana , Arial Black , Trebuchet MS , Arial Serif – Similar to newspaper fonts Times New Roman , Georgia Monospace – Have constant width characters Courier New , Agency FB Cursive – Look like handwritten text Comic Sans , Harrington Fantasy – Decorative styles Impact
  • 18. Style Sheet Example – 1 <html> <head> <style type=&quot;text/css&quot;> h1 {color: #00ff00} h2 {color: #dda0dd} p {color: rgb(0,0,255)} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
  • 19. Style Sheet Example – 2 <html> <head> <style type=&quot;text/css&quot;> h1 {text-align: center} h2 {text-align: left} h3 {text-align: right} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <h3>This is header 3</h3> </body> </html>
  • 20. Style Sheet Example – 3 <html> <head> <style type=&quot;text/css&quot;> h1 {text-decoration: overline} h2 {text-decoration: line-through} h3 {text-decoration: underline} a {text-decoration: none} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <h3>This is header 3</h3> <p> <a href=&quot;http://www.w3schools.com/default.asp&quot;> This is a link</a> </p> </body> </html>
  • 21. Style Sheet Example – 4 <html> <head> <style type=&quot;text/css&quot;> p.uppercase {text-transform: uppercase} p.lowercase {text-transform: lowercase} p.capitalize {text-transform: capitalize} </style> </head> <body> <p class=&quot;uppercase&quot;> This is some text in a paragraph </p> <p class=&quot;lowercase&quot;> This is some text in a paragraph </p> <p class=&quot;capitalize&quot;> This is some text in a paragraph </p> </body> </html>
  • 22. Style Sheet Example – 5 <html> <head> <style type=&quot;text/css&quot;> body {background-color: yellow} h1 {background-color: #00ff00} h2 {background-color: transparent} p {background-color: rgb(250,0,255)} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
  • 23. Style Sheet Example – 6 <html> <head> <style type=&quot;text/css&quot;> h3 {font-family: times} p {font-family: courier} p.sansserif {font-family: sans-serif} </style> </head> <body> <h3>This is header 3</h3> <p> This is a paragraph</p> <p class=&quot;sansserif&quot;> This is a paragraph</p> </body> </html>
  • 24. Style Sheet Example – 7 <html> <head> <style type=&quot;text/css&quot;> h1 {font-size: 150%} h2 {font-size: 130%} p {font-size: 100%} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
  • 25. Style Sheet Example – 8 <html> <head> <style type=&quot;text/css&quot;> p.normal {font-weight: normal} p.thick {font-weight: bold} p.thicker {font-weight: 900} </style> </head> <body> <p class=&quot;normal&quot;> This is a paragraph</p> <p class=&quot;thick&quot;> This is a paragraph</p> <p class=&quot;thicker&quot;> This is a paragraph</p> </body> </html>
  • 26. Style Sheet Example – 9 <html> <head> <style type=&quot;text/css&quot;> p.dotted {border-style: dotted} p.dashed {border-style: dashed} p.solid {border-style: solid} p.double {border-style: double} p.groove {border-style: groove} p.ridge {border-style: ridge} p.inset {border-style: inset} p.outset {border-style: outset} </style> </head> …
  • 27. Style Sheet Example – 10 <html> <head> <style type=&quot;text/css&quot;> h1, h2 { font-family: sans-serif; color: gray; border-bottom: 1px solid black } p { color: maroon; } </style> </head> <body> <h1> Welcome to my Page! </h1> <H2> How are you doing? </h2> <p>This is a paragraph</p> </body> </html>
  • 28. Style Sheet Example – 11 info.css h1, h2 { font-family: sans-serif; color: gray; } h1 { border-bottom: 1px solid black; } p { color: maroon; } main.html <html> <head> <title> External CSS Example </title> <link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;info.css&quot;> </head> <body> <h1> Welcome to my Page! </h1> <h2> How are you doing? </h2> <p>This is a paragraph</p> </body> </html>
  • 29. Style Sheet Example – 12 info.css .test { line-height: 1.9em; font-style: italic; font-family: Georgia, &quot;Times New Roman&quot;, Times, serif; color: #444444; border-color: black; border-width: 1px; border-style: solid; background-color: #a7cece; padding: 25px; margin: 30px; } main.html <html> <head> <title> External CSS Example </title> <link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;info.css&quot;> </head> <body> <h1> Welcome to my Page! </h1> <h2> How are you doing? </h2> <p class=&quot;test&quot;> This is a paragraph. See how this is decorated with the help of styles. We have all sorts of paragraph and background formattng features available, which allow us to format text the way we want to a very precise level. </p> </body> </html>
  • 30. Lists <html> <head> <style type=&quot;text/css&quot;> ul.disc { list-style-type: disc } ul.circle { list-style-type: circle } ul.square { list-style-type: square } …
  • 31. Thank you! Questions and Comments Welcome!