200 likes | 405 Views
CSS. Cascading Style Sheets (CSS). Basic rules of CSS Pseudo-class of the A tag Apply CSS to alter an unordered list. Background. HTML was intended to deliver data/text content. Attributes & formatting elements make site maintenance unorderly.
E N D
CSS Cascading Style Sheets (CSS) Basic rules of CSS Pseudo-class of the A tag Apply CSS to alter an unordered list
Background • HTML was intended to deliver data/text content. • Attributes & formatting elementsmake site maintenance unorderly. • Solution: separate web-content from page-formatting Cascading Style Sheet (e.g. <font>) Reference : http://www.howtocreate.co.uk/tutorials/css/introduction
Cascading Style Sheet selector1 { property : value } selector2 { property1: value1; property2: value2 }
Cascading Style Sheet Types of selectorsAffected elements • type (tags)p {. .}table, ul {. .} • class.headings {. .} • id#contentarea {. .} • combinationsp.para2 {. . . }table td .bluecell {. .}#contentarea p {. .} • pseudo-class selectors <p> </p><table> </table><ul> </ul> <xx class="headings">…</xx> <div id=“contentarea">…</div>
Cascading Style Sheet Where to add styles? • External stylesheets<link rel="stylesheet" type="text/css" href="css/global.css"> • Embedded/internal stylesheetbetween <style> . . </style> tag • Inline stylesstyle attribute<p style="text-align:center">
Cascading Style Sheet • Cascading effect of multiple stylesheets; • Overriding order; • Inheritance;
style1.css p {text-align: center;} style2.css p {color: red;} Cascading Style Sheet Cascading effect:CSS properties can accumulate or add-up. This paragraph is centre-aligned and in red
Cascading Style Sheet Overriding order:- which style wins? • A tag selector is worth 1 point. • A class selector is worth 10 points. • An ID selector is worth 100 points. • An inline style is worth 1000 points
Cascading Style Sheet Overriding order:- which style wins?
Cascading Style Sheet Overriding order:- which style wins? Tiebreaker : Last style wins p a.email { color: blue; } p.byline a { color: red; } <p class="byline">Written by<a class="email" href="mailto:jean@cosmofarmer.com">Jean Graine de Pomme</a></p> <p class="byline">Written by<a class="email" href="mailto:jean@cosmofarmer.com">Jean Graine de Pomme</a></p>
Cascading Style Sheet UL LI InheritanceCSS properties applied to one tag are passed on to nested tags. <li> tag inherits styles from <ul> (the parent tag) where applicable, unless re-styled explicitly otherwise.
Cascading Style Sheet List of properties and values http://www.eskimo.com/~bloo/indexdot/css/propindex/all.htm
Cascading Style Sheet HTML elements : inline or block? The BOX model – width, margin, border, padding
Cascading Style Sheet CSS positioning • Positioning types: • Normal (relative) • Float • Absolute http://www.brainjar.com/css/positioning/
Cascading Style Sheet CSS positioning • Positioning types: • Normal (relative) • Float • Absolute http://www.brainjar.com/css/positioning/
Albert Einstein #rightbar 180px Assignment einstein.html