More CSS.

Slides:



Advertisements
Similar presentations
CSS CSS Precise Aesthetic Control. Cascading Style Sheets Though they can be put in HTML header, usually a separate page that the HTML links to Contains.
Advertisements

Introduction to CSS.
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 Link Styling. The Anchor Element: Link text between the opening and closing can be styled using CSS. Some of the properties that can be set are: font-family,
กระบวนวิชา 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.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
HCI 201 Week 6 Client Side Image Maps Introduction to CSS.
SM5312 week 6: basic CSS syntax1 An Introduction to Cascading Style Sheets Basic CSS Syntax Nick Foxall.
CSSMR.Mostafa badr1. Lesson 3 Creating an Style Sheet Lesson 2 Structure of the Style Lesson 1: What Cascading Style Sheets are?
Using color and fonts in HTML and XHTML Please use speaker notes for additional information!
3.1 Cascading Style Sheets. Motto Fashions fade, style is eternal. —Yves Saint Laurent.
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.
Cascading Style Sheets 1 Color and Backgrounds. Cascading Style Sheets 2 Color and Backgrounds Computer color basics Expression of color values using.
IMAGES Controlling size of images in CSS Aligning images in CSS Adding background images.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
1 Web Developer Foundations: Using XHTML Chapter 9 Cascading Style Sheet Concepts.
Cascading Style Sheets Example
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
CSS Dvijesh Bhatt.
CSS Style Rules Guang Tong, Zhan L;lo’p[ Css Style Rule Guang Tong Zhan Three ways to insert CSS 1 External style sheet 2 Internal style sheet 3 Inline.
HTML - Quiz #2 Attendance CODE:
Cascading Style Sheet (CSS)
Tutorial #3 Cascading Style Sheets. Review: Last Class Image sizing Pathnames Project Default Path Relative Path Absolute Path Blackboard Homework Submission.
WRT235: Writing in Electronic Environments CSS Backgrounds, colors, fonts.
CSS in XHTML continued Please use speaker notes for additional information!
 HTML stands for Hyper Text Mark-up Language. The coding language used to create documents for the World Wide Web  HTML is composed of tags. HTML tags.
Doman’s Sections Information in this presentation includes text and images from
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
 A style sheet is a single page of formatting instructions that can control the appearance of many HTML pages at once.  If style sheets accomplished.
Tutorial #4 Formatting Text and Links. Tutorial #3 Review - CSS CSS format Selector { property1: value1; /* Comments */ } Embedded, In-Line, and External.
Just A Few More Fun Objectives 1 Having Some Fun With Java Script 2 Using Style Sheets.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
CO1552 – Web Application Development Cascading Style Sheets.
Tutorial #3 Cascading Style Sheets. Tutorial #2 Review - Anchors Links to Site DMACC Internal Links Go to Top Mail To me Local.
11/6/13 MORE CSS!. TODAY’S AGENDA Review: float for positioning objects Review: CSS and color Introductions to: o CSS and images o CSS backgrounds o CSS.
Cascading Style Sheets in.NET Lilian Kiilu, Client/Server & Web Applications, Coms 463/563, Section 1pm, Fall 2005, November 16 th 2005.
Introduction to CSS. What is CSS?  Cascading Style Sheets  Used for styling HTML  Also important in javascript and jquery for selectors  External.
Ch 8 HTML and CSS Web Standards Solutions A Web Standardistas’ Approach.
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.
CSS Cascading Style Sheets. CSS Advantages Greater typography and page layout control Style is separate from structure Styles can be stored in a separate.
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.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
CSS Tutorial 1 Introduction Syntax How to use style specifications. Styles.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
So far, we have looked at CSS selectors that correlate with HTML tags Now, we’ll see how you can define your own selectors using class and ID selectors.
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
DIV, Span, CSS.
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:
Microsoft Expression Web-Illustrated Unit F: Enhancing a Design with CSS.
Cascading Style Sheets Web Design Fairport High School.
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
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
Web Design (15) CSS Opacity, Link Colours & Background Images.
PERSPECTIVES: TUTORIAL 4 CREATING PAGE LAYOUTS WITH CSS.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
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,
1 Cascading Style Sheets
More CSS.
CSS Box Model.
CSS Box Model.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
CSS Box Model.
More CSS.
CSS Box Model.
Presentation transcript:

More CSS

More CSS Features Let's take a look at some more features available to us via CSS, as well as some techniques to make our CSS declarations more precise and efficient: Setting images as the background for elements. Customizing how text links look and behave on the page. Centering a <div> element on a page. Adding CSS comments. Styling multiple selectors with a single CSS declaration. Using CSS inheritance to style elements on a page.

Setting a Background Image Using CSS, we can place a background image on an element. By applying the style declaration to the <body> element, we can set the background for an entire page: body { background-image: url('sky.jpg'); } Notice that the name of the image file is surrounded by single quotes, not double quotes. This image was large enough to take up the entire height and width of the browser window. Let's explore what will happen with smaller images.

Repeating Backgrounds By default, the browser repeats our background image as many times as necessary, vertically and horizontally, until the entire window is filled. This is known as tiling. Let's use a smaller image than before: body { background-image: url('smiley.jpg'); } If we don't want the background image to repeat over the entire page, we have three other options: tile horizontally, tile vertically, or no tiling at all. Let's see how each looks with this image.

Tiling Options By setting the background-repeat property, we can control how the background image tiles on the screen: background-repeat: no-repeat; background-repeat: repeat-x; background-repeat: repeat-y; An image such as this smiley face does not make for a pleasant background, especially when tiled across the page. Not only is it distracting but it also makes text difficult to read. Many web designers will use a small graphic file that looks nearly seamless when it repeats horizontally and vertically.

Background Textures A repeated image that looks seamless is often referred to as a texture background and can make a website look more polished. Here are three sample textures:

Setting a Fallback Color Even if we set an image to be our page background, it's a good practice to set the background-color property also: body { background-image: url('texture.jpg'); background-color: gray; } If the background image is found, the color will not show (unless the image has transparent portions.) If for any reason the image file cannot be found, the browser will fall back to our color declaration.

Styling Text Links Like other text on the page, link text (between the opening <a> and closing </a> tags) can be styled using CSS. Some of the properties that can be set are: font-family font-size font-style font-weight color background-color text-decoration

Link States The <a> element is unusual in that it can be in one of four different conditions - or states - and we can define separate styles for each of these states. The four states are: a:link = unvisited link (default state) a:visited = previously visited link a:hover = link being moused over a:active = link being clicked Have you ever noticed upon returning to a web page after clicking one of its links that the text link you clicked earlier is now a different color? That's due to most browsers automatically styling unvisited and visited links differently. Let's see how we can override browser defaults and customize how text links look and behave on our web pages.

Example CSS Link Styling <head> <style type="text/css"> a:link { color: blue; } a:visited { color: green; a:hover { color: orange; a:active { color: red; </style> </head> ... <a href="http://www.google.com"> Link to Google </a> Link to Google Link to Google As we mouse over the link but before clicking on it. Link to Google Link to Google As we are actually clicking on the link. Warning #1: Do not put a space after a colon in the selector section. Doing so will result in the style declaration being ignored. Warning #2: Always list these properties and states in the order shown. Mixing their order on your style sheet can result in some of the styling not being applied.

Different Screen Sizes Because we don't know what the screen resolution will be for our visitors, it can be challenging to get our pages to display attractively for all viewers: .textbox { width: 400px; height: 480px; background-color: gray; text-align: center; } ... <div class="textbox"> <h1>The Road Not Taken</h1> <h3>by Robert Frost</h3> </div> 1280x720 Screen If we tried to set a large left margin for this <div> to center it on a wide monitor screen such as this one, then viewers with smaller screens would have the content cut off and would have to scroll right to view it.

Centering a <div> A technique to center a <div> on the screen, regardless of the screen resolution, is to set the right and left margins to auto: .textbox { width: 400px; height: 480px; margin: 0px auto; ... 1280x720 Screen 800x600 Screen 1024x768 Screen

CSS Comments Just as we added useful comments to our XHTML markup, we can add comments to our CSS code: .infobox { height: 200px; width: 150px; /*Do not make wider!*/ background-color: teal; } /* This footer section needs to be updated next January. */ .footer { text-align: center; /*font-weight: bold;*/ font-size: 24px; color: brown; Everything between the /* and */ will be disregarded, even if the comments span multiple lines. CSS comments are often used when experimenting with styles or troubleshooting problems. Rather than deleting style declarations and then retyping them again, we can just "comment them out" temporarily, evaluate the effect, and then restore the style by removing the /* and */ characters.

Multiple Selectors We can make our CSS code leaner and prevent extra typing by styling multiple selectors in the same declaration: h1 { color: blue; text-align: center; } .summary { #header { a:link { h1, .summary, #header, a:link { color: blue; } h1, #header { text-align: center; = Just place a comma between each selector and the style will be applied to the entire list. Each of the CSS code samples above accomplishes the same thing.

CSS Inheritance Some elements automatically inherit the CSS styling of the element that contains them. For example, the following properties affecting text will be inherited by child elements from their parent elements. font-family font-size font-style font-weight color text-align We can exploit this fact to make our styling easier. For example, if we have a <div> that contains <h3>, <p>, <ul>, and <li> elements, and we want to style all the elements to have the same font and color, we don't need to style each separately. We can just style the <div> directly and all the elements will inherit the style. Likewise, if we wanted the entire page to have the same text styling, we could style the <body> element itself. A child element will inherit a style only if there is not a more specific style applied to it. As designers, we always have the ability to override inheritance when we need to.