The Basics of Cascading Style Sheets (CSS)

Slides:



Advertisements
Similar presentations
Cascading Style Sheets
Advertisements

Cascading Style Sheets
Cascading Style Sheets (CSS): Pixel-Level Control with HTML Ease
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Objective: Cascading Style Sheets. Why use CSS? Where to use it?
CS4370/6370 Web Development Cascading Style Sheets (CSS)
CASCADING STYLE SHEETS CSS. 2 What CSS means?  CSS is an extension to basic HTML that allows you to style your web pages.  It separates the part that.
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
Cascading Style Sheets SP.772 May 6, CSS Useful for creating one unified look for an entire web site. Helps to seperate style from content. Can.
Web Design & Development Cascading Style Sheets (CSS)
4.01 Cascading Style Sheets
Lecture CSS: Cascading Style Sheets. What are Styles? Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Selectors thru Borders. CSS – Cascading Style Sheets – is a way to style HTML HTML is the content base of a web page CSS provides the presentation qualities.
Cascading Style Sheets 1 Color and Backgrounds. Cascading Style Sheets 2 Color and Backgrounds Computer color basics Expression of color values using.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order.
CSS Dvijesh Bhatt.
HTML - Quiz #2 Attendance CODE:
Cascading style sheets (CSS)
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
New Perspectives on XML, 2nd Edition Tutorial 5 1 TUTORIAL 5 WORKING WITH CASCADING STYLE SHEETS.
CSS Introduction Cascading Style Sheets Provides a great deal of control over the presentation of the document HTML indicates both semantics of a document.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
Doman’s Sections Information in this presentation includes text and images from
MCS 270 Cascading Style Sheets (CSS) Gustavus Adolphus College.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Cascading Style Sheet Bayu Priyambadha, S.Kom. Definition Cascading Style Sheets (CSS) form the presentation layer of the user interface. –Structure (HTML)
CSS. HTML: Looking Back HTML dictates order, structure, and function Does very little to specify layout or visual rendering.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
HTML - Quiz #2 Attendance CODE:
Lesson 03 // Cascading Style Sheets. CSS Stands for Cascading Style Sheets. We’ll be using a combination of Html and CSS to create websites. CSS is a.
More CSS.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
>> The “Box” Model. Pre-requisite Create a new project in Netbeans called Week5 Create a new html file and name it box.html Create a new css file and.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
DIV, Span, CSS.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
REEM ALMOTIRI Information Technology Department Majmaah University.
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
3.2 Cascading Style Sheets. 2 Positioning Elements Normally, elements are laid out on the page in the order that they are defined in the XHTML document.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Cascading Style Sheets Web Design Fairport High School.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
Developing Web Applications with HTML and CSS “Selectors and Properties”
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CSS: Cascading Style Sheets Part II. Style Syntax.
Coding with HTML {. THE BASICS { What is HTML and how can you use it to make websites?
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
PERSPECTIVES: TUTORIAL 4 CREATING PAGE LAYOUTS WITH CSS.
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
HTML & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
Unit 3 - Review. Topics 1. Tag, Attribute, Value 2. CSS Rule Syntax + link 3. Categories of Selectors 4. Inline vs Block Tags 5. CSS Layout 6. CSS Box.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Presentation transcript:

The Basics of Cascading Style Sheets (CSS) Cascading Style Sheets: Pixel-Level Control with HTML Ease

HTML: Looking Back HTML dictates order, structure, and function Does very little to specify layout or visual rendering With HTML, we developed learned about elements in which we could place our content. We built the items, but we’ve said nothing of how they should be painted, decorated, or arranged. Or, for an analogy combo, you could say that we’ve developed a vocabulary--of nouns, verbs, and a couple adjectives, perhaps, but a vocabulary nonetheless! With enough time we could certainly string together these elements and make a paper--we learned how to make tables and, my gosh, we even learned how to place in some dazzling figures! Well, okay, that might pass the muster for grad students, but well, we’re MIT students, and it’s IAP--so let’s not just make papers, let’s be a little creative. Let’s write some poetry!

Introduction What do you know about CSS? What do you hope to do with CSS? How familiar are you with HTML? Cascading Style Sheets: Pixel-Level Control with HTML Ease

Presentation Summary What is CSS? CSS & HTML The Box Model Style Sheet Implementation CSS Rule Structure HTML & DIVs Common CSS properties CSS Cascade and Inheritance Resources Cascading Style Sheets: Pixel-Level Control with HTML Ease

The Purpose of CSS If HTML is the content and meaning CSS helps to convey that meaning Allows developers to separate the content from layout and design Content and design inherently different in nature Change in content does not require change in design

CSS Zen Garden Site using consistent HTML content Differing external CSS files create dramatically different layout Support for multiple browsers link: http://www.csszengarden.com hint: change the styles on the page

An Example Meaning is conveyed by the styling Consider the boldface font in the following examples: Chunky bacon is delicious. Today I will go outside. Monday I will run 2 miles. Meaning is conveyed by the styling Remove the style and meaning is lost Attention is given to the information No additional meaning is lost when removed Say it out loud. The “chunky” is meant to be said strongly. If you lose the intonation and expression, some of the meaning is lost along with it. On the other hand, the bold font in the second example has no significant meaning. While it does help the viewer to read the data, it can be removed without losing the intrinsic value and meaning of the content. Say it out loud. The “chunky” is meant to be said strongly. If you lose the intonation and expression, some of the meaning is lost along with it.

What is CSS? Style.css /* Styles for sitename.com*/ body { font-family:Arial; background: #000; } #container { text-align:left; width:1020px; } #header { height:232px; } #footer { width: 100%; padding: 0 10px; margin-bottom: 10px; And so on…. CSS stands for Cascading Style Sheet. Typical CSS file is a text file with an extention.css and contains a series of commands or rules. These rules tell the HTML how to display. *To create a style sheet, create a file using Notepad (PC) or Text Edit (Mac), save it as a .css document and start writing the CSS code (see right). Cascading Style Sheets: Pixel-Level Control with HTML Ease

CSS Benefits Separates structure from presentation Provides advanced control of presentation Easy maintenance of multiple pages Faster page loading Better accessibility for new users Easy to learn Cascading Style Sheets: Pixel-Level Control with HTML Ease

HTML Without CSS “HTML without CSS is like a piece of candy without a pretty wrapper.” Without CSS, HTML elements typically flow from top to bottom of the page and position themselves to the left by default. With CSS help, we can create containers or DIVs to better organize content and make a Web page visually appealing. Cascading Style Sheets: Pixel-Level Control with HTML Ease

HTML & CSS HTML and CSS work together to produce beautiful and functional Web sites HTML = structure CSS = style Cascading Style Sheets: Pixel-Level Control with HTML Ease

The Box Model CSS works on the box model. A typical Web page consists of many boxes joined together from top to bottom. These boxes can be stacked, nested, and can float. Header Navigation Content Footer Cascading Style Sheets: Pixel-Level Control with HTML Ease

Typical Web Page (Browser) Container header menu main footer Cascading Style Sheets: Pixel-Level Control with HTML Ease

Attaching a Style Sheet Attach a style sheet to a page by adding the code to the <head> section of the HTML page. There are 3 ways to attach CSS to a page: 1. External Style Sheet: Best used to control styling on multiple pages. <link rel="stylesheet" type="text/css" media="all" href="css/styles.css" /> 2. Internal Style Sheet: Best used to control styling on one page. <style type=“text/css”> h1 {color: red) </style> 3. Inline Style Sheet*: CSS is not attached in the <header> but is used directly within HTML tags. <p style=“color: red”>Some Text</p> Cascading Style Sheets: Pixel-Level Control with HTML Ease

CSS Rule Structure A CSS RULE is made up of a selector and a declaration. A declaration consists of property and value. selector {property: value;} declaration Cascading Style Sheets: Pixel-Level Control with HTML Ease

Selectors A selector, here in green, is often an element of HTML. body { property: value; } h1 { property: value; } em { property: value; } p { property: value; } Cascading Style Sheets: Pixel-Level Control with HTML Ease

Properties and Values body {background: purple;} h1 {color: green; } h2 {font-size: large;} p {color: #ff0000;} /*hexadecimal for red*/ Properties and values tell an HTML element how to display. body { background: purple; color: green; } *CSS code can be written in a linear format (above) or in a block format (below). Cascading Style Sheets: Pixel-Level Control with HTML Ease

Grouping Selectors Group the same selector with different declarations together on one line. h1 {color: black;} h1 {font-weight: bold;} h1 {background: white;} Example of grouping selectors (both are correct): h1 { color: black; font-weight: bold; background: white; } Cascading Style Sheets: Pixel-Level Control with HTML Ease

Grouping Selectors h1 {color: yellow;} h2 {color: yellow;} Group different selectors with the same declaration on one line. h1 {color: yellow;} h2 {color: yellow;} h3 {color: yellow;} Example of grouping selectors (both are correct): h1, h2, h3 {color: yellow;} Cascading Style Sheets: Pixel-Level Control with HTML Ease

Comments in CSS Explain the purpose of the coding Help others read and understand the code Serve as a reminder to you for what it all means Starts with /*and ends with*/ p {color: #ff0000;} /*Company Branding*/ Cascading Style Sheets: Pixel-Level Control with HTML Ease

Paragraph To start off our understanding of cascading style sheets, we're going to use a special line of CSS code that does something HTML alone could never do right… we're going to indent every paragraph automatically. Here's the CSS code: p { text-indent: 3em; }

Working with Paragraph p { text-indent: 3em; } Then, right before your </head> tag in each page add a line similar to this: <link rel="stylesheet" type="text/css" href="main.css" title="Default"> This will link a new style sheet, location main.css, to each page. The title field is optional.

import  @import can be used in conjunction with the other methods. Imagine you want 2 pages out of your initial 10 pages to have, in addition to the normal indent, each and every paragraph in blue text. You could write a second style sheet, we'll call it coolblue.css, and inside that sheet you have: p { color: blue; }  

import Then, in those 2 special pages, you place the normal CSS link, but you'll add special code,@import, to add the extra color. <link rel="stylesheet" type="text/css" href="main.css" title="Default"> <style type="text/css"> <!-- @import url(coolblue.css); --></style>

Basis overview Those are the basics. Let's review the ways you can include a style sheet: Write it inline inside each and every tag Place a <style> </style> at the beginning of the web page Dedicate and link a CSS file and write it inside that file use @import to include it as portion of a page's CSS

Exercise 1 Use <style> to make all paragraphs have 10 spaces indentation (hint: 6em) and make the text red. Hint: Combine both into one line of code using the ; separator. Remember to create a paragraph in the <body> to see the style in action! Generic text below. This is the first paragraph with the red text and large indent. This is the second paragraph with the red text and large indent.

Solution <html> <head> <style type="text/css"> <!-- p { text-indent: 6em; color: red; } --></style> </head> <body> <p>This is the first paragraph<br> with the red text and large indent.</p> <p>This is the second paragraph<br>   </body> </html>

Headers If you want to make all H1, H2, and H3 red, and all H4, H5, H6 yellow, your style could look like this: h1, h2, h3 { color: red; } h4, h5, h6 { color: yellow; } You can use the comma to say you want to define a style for multiple selectors at the same time. You can set a style for nearly all HTML elements.

Selector a class of a current element Every paragraph is now indented. But what if you want a few paragraphs without an indent? We can define an extra selector. You can pick a name for these, I'm going to call minenoindent. Here's the original code with an added noindent selector: p { text-indent: 3em; } p.noindent { text-indent: 0em; } This says that any p that are part of a class called noindent should use 0em indentation. To call that in code, we use class. A normal paragraph looks like this: <p> I'm using a style with an indent. </p>

Normal paragraph A normal paragraph looks like this: <p> I'm using a style with an indent. </p> I'm using a style with an indent. A paragraph with the noindent looks like this: <p class="noindent"> I'm using a style without an indent. </p> I'm using a style without an indent. If you are going to only indent some paragraphs, but you probably won't indent most, you can just define a special paragraph called indent. p.indent { text-indent: 3em; } If that's our only style, regular <p> </p> will have no indent, while <p class="indent"> </p> will have a 3em indentation.

This h1 has an indent. Imagine a selector .g, defined as { color: green; }. Every time you use class="g" in an element the text color would be shown in green. ID selectors are used for special formatting of only a few elements. ID selectors use a # instead of a .. Imagine 3 paragraphs, we'll call them par1, par2, par3. We'll make one red, one orange, and one blue.

This h1 has an indent con’t We could use these styles: p#par1 { color: red; } p#par2 { color: orange; } p#par3 { color: blue; } <p id="par1">I'm in red</p> <p id="par2">I'm in orange</p> <p id="par3">I'm in blue</p> ID Selectors can also be element-less: #par1 { color: red; } ...would apply to all tags that specify id="par1".

PSEUDO-ELEMENTS There are two important pseudo-elements that are built into CSS capable web browsers. (There are also common pseudo-classes which you'll learn in the links chapter.) These two elements are :first-letter and :first-line. Notice that pseudo-elements are defined with a : instead of a . or # (this is because they have special meanings to a web browser). Here's a silly example for each: Imagine you want the first letter of each paragraph to be red, or the first-line of each paragraph to be green. p:first-letter { color: red; } p:first-line { color: green; }

CSS Background, Image and Color Styles You are probably familiar with the <body> tag. A typical <body> tag looks something like this: <body background="graphic.jpg" text="#FFFFFF" bgcolor="#000000"> To convert that into CSS, it looks like this: body { background-image: url(graphic.jpg); color: #FFFFFF; background-color: #000000; }

Con’t Big deal right? But CSS adds some special features. One of the most important is the background-repeat property. It has these values: repeat, repeat-x, repeat-y, or no-repeat. A regular web page has a default of background-repeat: repeat, which means the image is repeated both horizontally and vertically. With CSS, you can set the background to repeat horizontally (repeat-x), repeat vertically (repeat-y), or not repeat at all (no-repeat).

Images con’t We can edit the style mentioned above to have the body's background never repeat by adding background-repeat: no-repeat: body { background-image: url(graphic.jpg); color: #FFFFFF; background-color: #000000; background-repeat: no-repeat; } If you want to include the repeat in your standard background tag (for example, if are not using CSS for the rest of your page), you can add style="background-repeat: no-repeat;", so it looks like this: <body background="graphic.jpg" text="#FFFFFF" bgcolor="#000000" style="background-repeat: no-repeat;">

There are two more important background properties: background-attachment and background-position. background-attachment merely allows you to decide if you want the background to scroll or not. If you want it to scroll, use background-attachment: scroll. If you want it to not scroll, use background-attachment: fixed. background-position allows you to position the background. It takes two values, the first is the vertical position (in px [pixels], % [percent], or top, center, bottom) and the second value is the horizontal position (in px [pixels], % [percent], or left, center, right).

Key features If you want a background to be at the top right, use: background-position: top right. If you want it to be at the bottom center, use background-position: bottom center. This is typically most useful with background-repeat: no repeat.

Key Con’t As you can see, the coding for the background can get pretty long. CSS lets you combine it all into a single property statement, known as background. It follows this format: background: background-color || background-image || background-repeat || background-attachment || background-position If you want a background color of white, a background image lightpattern.jpg, the background to never repeat, and never scroll, you could use: body { background: #FFFFFF url(lightpattern.jpg) no-repeat fixed; }

Key Con’t Remember, you'll also need to set the text color, so add color: #000000 (if you want black text) body { background: #FFFFFF url(lightpattern.jpg) no-repeat fixed; color: #000000; } Notice that the browser is smart enough to realize that a value (in this case: background-position) is missing and it ignores that value. Always set a text and bgcolor in <body> for full browser compatibility.

Try a background with an element other than body Try a background with an element other than body. A good candidate is the p la la la la   <html> <head> <style type="text/css"> <!--  body { background: #EEEEEE url(/graphx/back.jpg) repeat-y scroll; }  --></style> </head> <body>la la la la </body> </html>  <html><head><style type="text/css"><!-- body { background: #FFFFFF url(/graphx/coddsite.gif) no-repeat fixed center left; }--></style></head><body></body></html>

Typical Web Page (Browser) Container header menu main footer Cascading Style Sheets: Pixel-Level Control with HTML Ease

Typical Web Page (HTML) Typical HTML Web page is made up of containers (boxes) or DIVs. Each DIV is assigned an ID or a Class. <div id=“container”> <div id=“header”>Insert Title</div> <div id=“main">content <div id=“menu”>content</div> </div> <div id=“footer”>content</div> Cascading Style Sheets: Pixel-Level Control with HTML Ease

Typical Web Page (CSS) The CSS file uses the same DIV/ID/Class names as the HTML and uses them to style the elements. #container {property: value;} #menu {property: value;} #main {property: value;} #footer {property: value;} Cascading Style Sheets: Pixel-Level Control with HTML Ease

IDs and Classes IDs (#) are unique and can only be used once on the page Classes (.) can be used as many times as needed HTML Code: <h1 id=“mainHeading”>Names</h1> <p class=“name”>Joe</p> CSS Code: #mainHeading {color: green} .name {color: red} Cascading Style Sheets: Pixel-Level Control with HTML Ease

CSS Box Properties Background-color Width Padding Margin Border-width Border-color Border-style Cascading Style Sheets: Pixel-Level Control with HTML Ease

HTML CSS div id=“header” div id=“content” div id=“footer” #content { background-color: #ccc; margin-bottom: 10px; border: 1px dashed blue; color: #fff; width: auto; } div id=“content” div id=“footer” Cascading Style Sheets: Pixel-Level Control with HTML Ease

The <div> tag The <div> tag is nothing more than a container unit that encapsulates other page elements and divides the HTML document into sections. Web developers use <div> elements to group together HTML elements and apply CSS styles to many elements at once. For instance, by wrapping a set of paragraph elements into a <div> element, the we can take advantage of CSS styles and apply a font to all paragraphs at once by applying a font style to the <div> tag instead of coding the same style for each paragraph element.

Common CSS Layout Properties Width Height Float Clear Border Padding Margin margin padding width height border Cascading Style Sheets: Pixel-Level Control with HTML Ease

Width & Height div id=“box” Width and height define the width and height of an element. div id=“box” #box {height=“auto”} #box {width=“50px”} #box {width=“50em”} #box {width=“100%”} #box {width=“auto”} *Width and height can be specified in pixels, ems, percentages or set to auto Cascading Style Sheets: Pixel-Level Control with HTML Ease

Float: (left, right) Float property makes elements float to the right or left of the screen, positioned where they are in the HTML. Floating allows word wrapping. Here is some text which wraps around the box floated to the left. div id=“box” #box {float:left; margin-right: 10px;} Cascading Style Sheets: Pixel-Level Control with HTML Ease

Clear: (left, right, both) When elements are floated, they wrap around each other to form a “caravan.” The clear property detaches an element from the “caravan” and allows it to start on a new line. div id=“box1” div id=“box2” div id=“box3” #box3 { background-color: white; border: 1px solid #000; clear: both;} Cascading Style Sheets: Pixel-Level Control with HTML Ease

Border (top, right, bottom, left) div id=“box” You can define the entire border or only the top, bottom, left, or right. You can also define the border using one declaration. The code could be any of the following: #box { border: red dotted 1px; #box { border-color: red; border-style: dotted; border-width: 2px; #box { border-top: red dotted 1px; border-bottom: red dotted 1px; border-left: red dotted 1px; border-right: red dotted 1px; } Cascading Style Sheets: Pixel-Level Control with HTML Ease

Padding (top, right, bottom, left) Padding is the space between the text/content and the border. You can use padding for all around the element or specify each side of the rectangle separately. The code could be any of the following: div id=“box” padding padding: 10px; Padding: 10px 10px; padding: 10px 10px 10px 10px; padding-left: 10px; padding-right: 10px; padding-bottom: 10px; padding-top: 10px; Cascading Style Sheets: Pixel-Level Control with HTML Ease

Margin (top, right, bottom, left) Margin is the space outside the text/content and the border. You can use margin for all around the element or specify each side of the rectangle separately. The code could be any of the following: margin margin: 10px; or margin: 10px 10px; margin: 10px 10px 10px 10px; margin-left: 10px; margin-right: 10px; margin-bottom: 10px; margin-top: 10px; div id=“box” Cascading Style Sheets: Pixel-Level Control with HTML Ease

Text Properties MAIN HEADING .mainHeading { color: red; letter-spacing: 5px; text-transform: uppercase; word-spacing: 15px; text-align: left; font-family: Times; text-decoration: underline; font-size: 12px; font-style: italic; font-weight: bold; } MAIN HEADING Gravida lacinia velit. Vivamus tortor enim, tincidunt at, pellentesque ut, iaculis eu, quam. To style the main heading in the paragraph above, we assigned a class the HTML tag. <h3 class=“mainHeading”>Main Heading</h3> Cascading Style Sheets: Pixel-Level Control with HTML Ease

CSS Colors #ffffff White #fff Black #cccf0f3 Blue Fuchsia Gray Green Standard Hexadecimal #ffffff #fff #cccf0f3 White Black Blue Fuchsia Gray Green Lime Aqua Cascading Style Sheets: Pixel-Level Control with HTML Ease

Styling Links The links property defines how inactive, hovered, active, and visited link states appear to the user. a:link {color: red; text-decoration: none;border-bottom: 1px dashed red; background: white;} a:visited {color: yellow;} a:active {color: green;} a:hover {color: orange;} Cascading Style Sheets: Pixel-Level Control with HTML Ease

Including Images Properties for working with images include: Background-image Background-repeat Background-position Background-attachment Cascading Style Sheets: Pixel-Level Control with HTML Ease

Layering div id=“bg” div id=“main” div id=“box” Background colors and images are layered like sheets of paper one on top of the other. #bg {background:url(leaves.jpg) no-repeat top left} #main {background-color: red} #box {background-color: yellow} Cascading Style Sheets: Pixel-Level Control with HTML Ease

Background-Image The background-image property sets an image in the background of an element. Background images and colors are layered. If not transparent, the last one listed in the CSS file is visible. li { background-image:url(flower.jpg); padding-left: 10px; } Cascading Style Sheets: Pixel-Level Control with HTML Ease

Background-Repeat The background-repeat property sets an image in the background of an element and tiles, or repeats, it. Tiling is the default. li { background-image:url(flower.jpg); background-repeat:no-repeat; } repeat repeat-x (horizontal) repeat-y (vertical) no-repeat Possible Values > Cascading Style Sheets: Pixel-Level Control with HTML Ease

Image Positioning left top center top The background-position property positions the image using either combined keywords (top, bottom, left, right, and center); length values; or percentage values. left bottom center bottom right bottom The background-attachment property fixes or scrolls an image in the browser window. Values include fixed and scroll. background-position: right top; /*can also use number values*/ background-attachment: fixed; /*can also use ‘scroll’*/ Cascading Style Sheets: Pixel-Level Control with HTML Ease

The Power of Cascade When multiple styles or style sheets are used, they start to cascade and sometimes compete with one another due to CSS’s inheritance feature. Any tag on the page could potentially be affected by any of the tags surrounded by it. So, which one wins? Nearest Ancestor Wins. Inline style or directly applied style The last style sheet declared in the <header> section Cascading Style Sheets: Pixel-Level Control with HTML Ease

Saving Time with Inheritance In a nutshell, inheritance (not the money you get from your grandma) is the process by which CSS properties applied to one tag are passed on to nested tags. For example, the paragraph tag will inherit the same styling as the body tag because <p> is always located inside <body>. <body style=“font-family: Arial”> <p>This text will be Arial as well</p> </body> So, instead of styling each paragraph separately, you can define the font color in the <body>, and everything inside will have that color. Cascading Style Sheets: Pixel-Level Control with HTML Ease

Resources “CSS: The Missing Manual” - by David Sawyer McFarland http://www.w3schools.com/css/css_reference.asp (list of all CSS properties) http://www.w3schools.com/css/ http://www.glish.com/css/ http://www.html.net/tutorials/css/ http://blog.html.it/layoutgala/ Great Book “CSS: The Missing Manual” - by David Sawyer McFarland Cascading Style Sheets: Pixel-Level Control with HTML Ease

Thank You I hope you enjoyed this presentation and learned some basic CSS. I hope this will help with creating beautiful and functional Web sites. Cascading Style Sheets: Pixel-Level Control with HTML Ease