SlideShare a Scribd company logo
CSS- Cascading Stylesheets   Layout for web  and XML
Cascading Stylesheets A language to define how XML documents, html documents and XHTML documents should be rendered for screen, paper, TV, sound … Reommendation from W3C Not in itself XML-based, but operates on XML structures
CSS - Historical perspektive html was built to structure text documetns with links, regardless of presentation medium. The commercial success of the web drove a need to make more estetically pleasing content. Logical elements (like <h3>) was used to get a certain graphical effect, instead of using it to indicate a logical content. New elements added without control. Solution: Make an entirely new language for laout: CSS
Examples Now File b.css p { font-family: Helvetica, sans-serif; } File b.html <?xml-stylesheet type=&quot;text/css&quot; href=&quot;b.css&quot;?> […] <p> Text in helvetica </p> […] Before File a.html […] <p> <font face=&quot;Helvetica&quot;> Text in Helvetica </font> </p> […]
Internal or external CSS A CSS can either be placed in the actual xml/html document, or as an external filef. An internal CSS has the advantage that only one http request is required However, the drawback is that copies of the CSS code must be placed in all documents using it, making updates more difficult.
Associating an  XML-document ->CSS type: MIME-typen text/css href: URI to the css-file charset: Character set title: Title media: The media for which the stylesheet should be used.An XML document can have several associated stylesheets. Which one(s) is used depends on the output medium:  Screen, tty, tv, projection, handheld, print, braille, aural or all To associate an XML document with a CSS, a processing instruction can be used. Processin instruction in an XML-fil <?xml-stylesheet  type=&quot;text/css&quot;  href=&quot;b.css&quot; charset=&quot;ISO8859-1&quot; title=”My Stylesheet&quot; media=&quot;screen&quot;?>
Associating an  HTML-document ->CSS An internal CSS can be added using the style-element in the element head. internal CSS in an HTML.-fil <html> <head> <style type=&quot;text/css&quot;> body {   background-color: #ffffff;   }</style> </head> <body> … </body> </html> To associate an html document with a CSS, you usually ad a link-element in the head-element. External CSS + HTML-file <html> <head> <link rel=&quot;stylesheet”  type=&quot;text/css&quot; href=&quot;test.css”/> </head> <body> … </body> </html>
Basic principle: Pattern -> Behaviour The basic principle is to find different ”patterns” in the XML/html using ”selectors”, and then setting some property to some value. A pattern can, for example, be a tag name. A property can be a font-size.   Example: p { font-family: Helvetica, sans-serif; }   Selector: All p-elements Property Property value
Different selectors There are a number of selectors that can be used to find different parts of an XML/html structure. For example, you can find decendents, children, siblings and attributes. Example: * { font-size: Medium } p a { font-size: Medium } Matches   all elements matches all a-elements which are decendents to p-elements
Different selectors Example: p > a { font-size: Medium } p + a { font-size: Medium } Matches a-elements which are children to p-elements. Matches all a-elements which directly follows a p-elements (siblings) Example: <p> <a></a> </p> <p> <strong> <a>Hej</a> </strong> </p> Matches Matches inte
Matching attributes Example: a-element wit href=&quot;a.html&quot; a[href=&quot;a.html&quot;] {font-size: Medium} a-element which has a href-attribut a[href] {font-size: Medium} a-element whose href contains the substring &quot;html&quot; a[href~=&quot;html&quot;] {font-size: Medium} Examples of attribute matches if the attribute has a value Substrings of attribute values ID-values
Pseudo classes and pseudo elements Example: First child to a  p-element p:first-child {font-size: Medium} First letter in a  banana-element banana:first-letter {font-size: Medium} Before (or after) a  banan-element banana:before {content: ”A Banana!&quot;} Pseudo classes and pseudo elements matches different types of meta information in the document. Separated from elements/attributeses with a colon.
There are a number of properties to set height, lenght and sizes. border-width, font-size, line-height, margin-left, margin-top, margin-right, margin-bottom, left, top, height, width Most units used in typography can be used. Absolute, t.ex. cm, in, pt Relative.ex. em, ex, px Example banana {line-height: 2.2em} tomato {font-size:14pt;line-height:3ex} Properties: Height/length/size Obs! Två properties till samma selektor, separerat med semikolon
Properties:Fonter A number of properties for font handling. font-family: i.e. Helvetica, sans-serif font-style: i.e. italic, slanted font-size: absolute values like 12pt or relative values like x-small font-weight: bold, bolder, lighter or a scale of 100 - 900 font-stretch:wider, ultra-expanded, semi-condensed and so forth. …  and several other properties
Properties:Texts Text-properties deals with indent, alignment and simple transformations. Display: block, inline or none. Blocks start on a new-line and is followed by a new-line, inline does not disrupt the text flow, and ”none” hides the content. text-indent: applicable only on elements with block-display. text-align: left, right, center, justify text-decoration: underline, overline, linethrough text-transform: capitalize, uppercase, lowercase white-space: pre to preserve linebreaks and whitespace.
Properties:Colours The most important properties or colours are Color (note: american spelling) Background-color Border-color Pre-defined colours Aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow Or hexadecimala colours representations p {color: # FF FF CC } or p {color:rgb( 100%, 100%, 70%}
Advanced 1: Counters It is also possible to use ”variables” as counter, and insert the value of the counters in what is displayed. p:before { content: counter(banana) &quot;. &quot;; counter-increment: banana } h1 { counter-reset: banana }
Advanced 2: Classes If you want to set different properties just to some elements of a certain kind, you can use ”classes”. p.tomato { font-size:14pt } … <p class=&quot;tomato&quot;> Hello </p>
Advanced 3:  Pseudoclasses for links It is common to want different colours on links, depending on whether they have been visited or not. a:link {color: #FF0000}  /* unvisited link */ a:visited {color: #00FF00}  /* visited link */ a:hover {color: #FF00FF}  /* mouse over link */ a:active {color: #0000FF}  /* selected link */
Advanced 4:  media types A way to define different properties for diferent media types, i.e. print, screen and aural. <html> <head> <style type=&quot;text/css&quot; media=&quot;screen&quot;> @import &quot;/css/initial.css&quot;; @import &quot;/css/screen.css&quot;; </style> <style type=&quot;text/css&quot; media=&quot;print&quot;> @import &quot;/css/initial.css&quot;; @import &quot;/css/print.css&quot;; </style> </head> <body> <p class=&quot;test&quot;>Hello</p> </body> </html>
Advanced 5: the print media type A few properties exist only for the media type &quot;print&quot;. The most important are: page-break-after page-break-before For more info, see  http://www.w3schools.com/css/css_ref_print.asp
Advanced 6: mediatypen aural An interesting possibility is to control the audio from a voice synthesizer. An example could be: h1, h2, h3, h4 { voice-family: male; richness: 80; cue-before: url(&quot;beep.au&quot;) } For more info, see http://www.w3schools.com/css/css_ref_aural.asp
Browsersupport Today good support in all(most) modern browsers.  Opera probably best support  However: Don’t count on mobile phones to support CSS.
Limitations and possibilities I CSS1: Only support for html-tags I CSS2: Supports all XML documents, making it easier to separate content from presentation. I CSS3: Support for columns, pagination, more powerful selectors and for non-european character sets. A problem is that it is not possible to change the orders of elements, or to re-use an element several times.

More Related Content

PPT
Web publishing and XHTML
PPT
Html Intro2
PPTX
Html basic tags
PPTX
HTML Basics by software development company india
PPT
Html basic
PPT
Web Development using HTML & CSS
PPT
Design Tools Html Xhtml
Web publishing and XHTML
Html Intro2
Html basic tags
HTML Basics by software development company india
Html basic
Web Development using HTML & CSS
Design Tools Html Xhtml

What's hot (20)

PPTX
Class2
PPTX
What is xml
PDF
[Basic HTML/CSS] 1. html - basic tags
PPTX
Basics of HTML 5 for Beginners
PPTX
Html, CSS & Web Designing
PPTX
HTML Introduction
PPTX
The Difference between HTML, XHTML & HTML5 for Beginners
ODP
Creating Web Sites with HTML and CSS
PPTX
PDF
Michael(tm) Smith ED09 presentation
PPTX
HTML Basic Tags
PPTX
HTML Basic, CSS Basic, JavaScript basic.
PPT
Html For Beginners 2
PDF
Intro to HTML (Kid's Class at TIY)
PPTX
Ict html
PPTX
PPS
Quick Referance to WML
PPT
PPT
Class2
What is xml
[Basic HTML/CSS] 1. html - basic tags
Basics of HTML 5 for Beginners
Html, CSS & Web Designing
HTML Introduction
The Difference between HTML, XHTML & HTML5 for Beginners
Creating Web Sites with HTML and CSS
Michael(tm) Smith ED09 presentation
HTML Basic Tags
HTML Basic, CSS Basic, JavaScript basic.
Html For Beginners 2
Intro to HTML (Kid's Class at TIY)
Ict html
Quick Referance to WML
Ad

Viewers also liked (7)

ODP
Presentacion Gpe 2005
PPT
Now We Are Friends, Now We Are
PDF
Medical images in the "cloud" by Ándago
PPT
Placas Rojas
PPT
Organise your information chaos
PPT
Monday Notes #9 11 4 07
Presentacion Gpe 2005
Now We Are Friends, Now We Are
Medical images in the "cloud" by Ándago
Placas Rojas
Organise your information chaos
Monday Notes #9 11 4 07
Ad

Similar to CSS (20)

PPT
CSS Part I
ODP
Cascading Style Sheets - Part 01
PPT
Introduction to Cascading Style Sheets
PPT
PPT
PPT
PPTX
(Fast) Introduction to HTML & CSS
PPT
Html Expression Web
PPTX
Markup Documents
PDF
PPT
Css 2010
PPT
Css 2010
PPT
Cascading Style Sheets
PPT
PPT
AK css
CSS Part I
Cascading Style Sheets - Part 01
Introduction to Cascading Style Sheets
(Fast) Introduction to HTML & CSS
Html Expression Web
Markup Documents
Css 2010
Css 2010
Cascading Style Sheets
AK css

More from bjornh (20)

PPT
Info kexjobb-2013-11-11
PPT
Info om masterval och kexjobb, medieteknik KTH VT2013
PPTX
Teaching procrastination - A way of helping students to improve their study h...
PPT
Info masterval medieteknik på KTH 2012-05-03
PPT
Info masterval och kexjobb i medieteknik KTH HT 2011
PPT
LIKT seminar on mobile learning
PPT
Location-based mLearning reminders
PPT
K-Seminar on mobile learning
PPT
Podcastseminarium
PPT
Web 2.0
PPT
XML Schemas
PPT
XSL-FO
PPT
RDF och RSS
PPT
Namespaces
PPT
Device Independence
PPT
XSLT
PPT
CSS
PPT
PHP och MySQL
PPT
Web 2.0
PPT
XML och DTD
Info kexjobb-2013-11-11
Info om masterval och kexjobb, medieteknik KTH VT2013
Teaching procrastination - A way of helping students to improve their study h...
Info masterval medieteknik på KTH 2012-05-03
Info masterval och kexjobb i medieteknik KTH HT 2011
LIKT seminar on mobile learning
Location-based mLearning reminders
K-Seminar on mobile learning
Podcastseminarium
Web 2.0
XML Schemas
XSL-FO
RDF och RSS
Namespaces
Device Independence
XSLT
CSS
PHP och MySQL
Web 2.0
XML och DTD

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
KodekX | Application Modernization Development
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Spectroscopy.pptx food analysis technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
KodekX | Application Modernization Development
20250228 LYD VKU AI Blended-Learning.pptx
Approach and Philosophy of On baking technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Diabetes mellitus diagnosis method based random forest with bat algorithm

CSS

  • 1. CSS- Cascading Stylesheets Layout for web and XML
  • 2. Cascading Stylesheets A language to define how XML documents, html documents and XHTML documents should be rendered for screen, paper, TV, sound … Reommendation from W3C Not in itself XML-based, but operates on XML structures
  • 3. CSS - Historical perspektive html was built to structure text documetns with links, regardless of presentation medium. The commercial success of the web drove a need to make more estetically pleasing content. Logical elements (like <h3>) was used to get a certain graphical effect, instead of using it to indicate a logical content. New elements added without control. Solution: Make an entirely new language for laout: CSS
  • 4. Examples Now File b.css p { font-family: Helvetica, sans-serif; } File b.html <?xml-stylesheet type=&quot;text/css&quot; href=&quot;b.css&quot;?> […] <p> Text in helvetica </p> […] Before File a.html […] <p> <font face=&quot;Helvetica&quot;> Text in Helvetica </font> </p> […]
  • 5. Internal or external CSS A CSS can either be placed in the actual xml/html document, or as an external filef. An internal CSS has the advantage that only one http request is required However, the drawback is that copies of the CSS code must be placed in all documents using it, making updates more difficult.
  • 6. Associating an XML-document ->CSS type: MIME-typen text/css href: URI to the css-file charset: Character set title: Title media: The media for which the stylesheet should be used.An XML document can have several associated stylesheets. Which one(s) is used depends on the output medium: Screen, tty, tv, projection, handheld, print, braille, aural or all To associate an XML document with a CSS, a processing instruction can be used. Processin instruction in an XML-fil <?xml-stylesheet type=&quot;text/css&quot; href=&quot;b.css&quot; charset=&quot;ISO8859-1&quot; title=”My Stylesheet&quot; media=&quot;screen&quot;?>
  • 7. Associating an HTML-document ->CSS An internal CSS can be added using the style-element in the element head. internal CSS in an HTML.-fil <html> <head> <style type=&quot;text/css&quot;> body { background-color: #ffffff; }</style> </head> <body> … </body> </html> To associate an html document with a CSS, you usually ad a link-element in the head-element. External CSS + HTML-file <html> <head> <link rel=&quot;stylesheet” type=&quot;text/css&quot; href=&quot;test.css”/> </head> <body> … </body> </html>
  • 8. Basic principle: Pattern -> Behaviour The basic principle is to find different ”patterns” in the XML/html using ”selectors”, and then setting some property to some value. A pattern can, for example, be a tag name. A property can be a font-size. Example: p { font-family: Helvetica, sans-serif; } Selector: All p-elements Property Property value
  • 9. Different selectors There are a number of selectors that can be used to find different parts of an XML/html structure. For example, you can find decendents, children, siblings and attributes. Example: * { font-size: Medium } p a { font-size: Medium } Matches all elements matches all a-elements which are decendents to p-elements
  • 10. Different selectors Example: p > a { font-size: Medium } p + a { font-size: Medium } Matches a-elements which are children to p-elements. Matches all a-elements which directly follows a p-elements (siblings) Example: <p> <a></a> </p> <p> <strong> <a>Hej</a> </strong> </p> Matches Matches inte
  • 11. Matching attributes Example: a-element wit href=&quot;a.html&quot; a[href=&quot;a.html&quot;] {font-size: Medium} a-element which has a href-attribut a[href] {font-size: Medium} a-element whose href contains the substring &quot;html&quot; a[href~=&quot;html&quot;] {font-size: Medium} Examples of attribute matches if the attribute has a value Substrings of attribute values ID-values
  • 12. Pseudo classes and pseudo elements Example: First child to a p-element p:first-child {font-size: Medium} First letter in a banana-element banana:first-letter {font-size: Medium} Before (or after) a banan-element banana:before {content: ”A Banana!&quot;} Pseudo classes and pseudo elements matches different types of meta information in the document. Separated from elements/attributeses with a colon.
  • 13. There are a number of properties to set height, lenght and sizes. border-width, font-size, line-height, margin-left, margin-top, margin-right, margin-bottom, left, top, height, width Most units used in typography can be used. Absolute, t.ex. cm, in, pt Relative.ex. em, ex, px Example banana {line-height: 2.2em} tomato {font-size:14pt;line-height:3ex} Properties: Height/length/size Obs! Två properties till samma selektor, separerat med semikolon
  • 14. Properties:Fonter A number of properties for font handling. font-family: i.e. Helvetica, sans-serif font-style: i.e. italic, slanted font-size: absolute values like 12pt or relative values like x-small font-weight: bold, bolder, lighter or a scale of 100 - 900 font-stretch:wider, ultra-expanded, semi-condensed and so forth. … and several other properties
  • 15. Properties:Texts Text-properties deals with indent, alignment and simple transformations. Display: block, inline or none. Blocks start on a new-line and is followed by a new-line, inline does not disrupt the text flow, and ”none” hides the content. text-indent: applicable only on elements with block-display. text-align: left, right, center, justify text-decoration: underline, overline, linethrough text-transform: capitalize, uppercase, lowercase white-space: pre to preserve linebreaks and whitespace.
  • 16. Properties:Colours The most important properties or colours are Color (note: american spelling) Background-color Border-color Pre-defined colours Aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow Or hexadecimala colours representations p {color: # FF FF CC } or p {color:rgb( 100%, 100%, 70%}
  • 17. Advanced 1: Counters It is also possible to use ”variables” as counter, and insert the value of the counters in what is displayed. p:before { content: counter(banana) &quot;. &quot;; counter-increment: banana } h1 { counter-reset: banana }
  • 18. Advanced 2: Classes If you want to set different properties just to some elements of a certain kind, you can use ”classes”. p.tomato { font-size:14pt } … <p class=&quot;tomato&quot;> Hello </p>
  • 19. Advanced 3: Pseudoclasses for links It is common to want different colours on links, depending on whether they have been visited or not. a:link {color: #FF0000} /* unvisited link */ a:visited {color: #00FF00} /* visited link */ a:hover {color: #FF00FF} /* mouse over link */ a:active {color: #0000FF} /* selected link */
  • 20. Advanced 4: media types A way to define different properties for diferent media types, i.e. print, screen and aural. <html> <head> <style type=&quot;text/css&quot; media=&quot;screen&quot;> @import &quot;/css/initial.css&quot;; @import &quot;/css/screen.css&quot;; </style> <style type=&quot;text/css&quot; media=&quot;print&quot;> @import &quot;/css/initial.css&quot;; @import &quot;/css/print.css&quot;; </style> </head> <body> <p class=&quot;test&quot;>Hello</p> </body> </html>
  • 21. Advanced 5: the print media type A few properties exist only for the media type &quot;print&quot;. The most important are: page-break-after page-break-before For more info, see http://www.w3schools.com/css/css_ref_print.asp
  • 22. Advanced 6: mediatypen aural An interesting possibility is to control the audio from a voice synthesizer. An example could be: h1, h2, h3, h4 { voice-family: male; richness: 80; cue-before: url(&quot;beep.au&quot;) } For more info, see http://www.w3schools.com/css/css_ref_aural.asp
  • 23. Browsersupport Today good support in all(most) modern browsers. Opera probably best support However: Don’t count on mobile phones to support CSS.
  • 24. Limitations and possibilities I CSS1: Only support for html-tags I CSS2: Supports all XML documents, making it easier to separate content from presentation. I CSS3: Support for columns, pagination, more powerful selectors and for non-european character sets. A problem is that it is not possible to change the orders of elements, or to re-use an element several times.