180 likes | 369 Views
Cascading Style Sheets. Cascading Style Sheets. Purpose Define Styles HTML Class ID Add style Inline Single page Entire site. Cascading Style Sheets. Intended as a way to eliminate need for formatting on each page Allows you to change all style at once
E N D
Cascading Style Sheets • Purpose • Define Styles • HTML • Class • ID • Add style • Inline • Single page • Entire site
Cascading Style Sheets • Intended as a way to eliminate need for formatting on each page • Allows you to change all style at once • Quickly change the appearance of a huge site
Cascading Style Sheets • More detail • Remove link underline • More control • Redefine HTML • Pixel precision placement • Layer objects • Faster Loading
Cascading Style Sheets • Style • Definition of attribute • Selector • Individual styles • CSS Code • Tag { property:value;}
Selector • HTML Selector • Redefine HTML tags • Class Selector • Definitions that can be used for multiple tags • ID Selector • Define object positioning
HTML Selector • Redefine an entire tag • Example body { background-color: black; } • When <body> is used, background will be black
Class Selector • Can be used by multiple HTML tags • Example .important { font-size:36px; color:blue; text-decoration:underline; }
Class Selector • <p class=“important”> • Result: • Look at Me • <b class=“important> • Look over here • Flexibility
ID Selector • Define objects, mostly used to layer • Example #adcol { position: absolute; right: 10px; top: 210px; width: 160px; height: 600px; }
ID Selector • Will create a text box that remains in one position regardless of other items on page • Imagine layering pictures, or cells of tables to create interactive menus
<SPAN> and <DIV> • Dummy tags • Useless by themselves • Carriers • Very powerful when paired with Class or ID Selectors • <span> • Inline • <div> • Block tag
Grouping • Multiple tags can be defined together h1,h2,h3,h4,h5,h6 { color: white; font-variant: small-caps; }
Placement • Inline • Within a page, within a specific tag • <p style=“font-size:100px;”> • That paragraph will be huge • Cannot be reused • DO NOT DO THIS
Placement • <head> section • Definitions for that entire page • All style in one spot • Easy to change • Helpful if one page is to be drastically different • Downside • Need to repeat for each page
Placement • External Sheet • Separate HTML document • Saved as .css • Reference by using <link> <head> <link href=“format.css” type=“text/css”> • All that needs to be done is to add this into every head section • And create a style page
Placement • Priority of CSS • Inline – 1st • Page • External – last