Docsity

Understanding CSS: Selectors, Rules, and Application - Prof. Nelson Padua-Perez, Study notes of Computer Science

Partial preview of the text

Download Understanding CSS: Selectors, Rules, and Application - Prof. Nelson Padua-Perez and more Study notes Computer Science in PDF only on Docsity!

Announcements



Great HTML Reference:

Web Design in a

Nutshell

by Jennifer Niederst,.

CSS (Cascading Style Sheets)^ CSS (Cascading Style Sheets)  Official W3C standard for controlling presentation  Specification: http://www.w3.org/TR/CSS21/  Style Sheets  Text file with rules. It includes no html.  Style sheets files use a .css extension  Allows you to apply typographic styles (font size, linespacing, etc.)  Allows you to apply spacing instructions  Allows you to have page layout control  Allows you to generate smaller html files by avoidingredundancy in style specification  Allows you to easily update a collection of pages byupdating only a single file

CSS^ CSS^  To apply formatting information to an html documentyou can  inline style directions  style elements at the top of the html file  external files which are linked or imported  Example (inline) โ€“ use only if you want to overridehigher-level rules. Avoid if possible.  Example: example1.html (top of html file) โ€“ Usingthe
CSS^ CSS  Why cascading?  Rules can come from different sources (inline, external file,etc.). The final set of rules that apply to a document comesfrom cascading all the sources.  Rule Conflict Resolution  To resolve conflicts, styles defined at a specific leveloverride those set at a higher levelExample: you can set the color of body text to be blue butyou can override to red the text in a list  When multiple style files are linked or imported the last willtake precedence

Selectors^ Selectors^  class selector  Allows you to identify html elements as part of agroup  To specify a style use the html selector followedby a period and the class name h1.firstGroup {color: blue}  Example: example4.html  To apply a format choice to all elements of agroup omit the tag name in the html selector .secondGroup {color: purple}

Selectors^ Selectors^  Pseudo-classes  Pseudo-classes applying to tag  A:visited {color: green}  A:active {color: maroon}  A:link{color: black}  Example: example5.html