In the early days of the Web, designers just had the original 91 HTML tags to work with.

Similar documents
CS 350 Internet Applications I Name: Exam II (CSS) October 29, 2013

CSS: The Basics CISC 282 September 20, 2014

CSS: Cascading Style Sheets

CSS Cascading Style Sheets

Cascading Style Sheets (CSS)

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

Appendix D CSS Properties and Values

Assignments (4) Assessment as per Schedule (2)

Lab Introduction to Cascading Style Sheets

CSS worksheet. JMC 105 Drake University

Introduction to WEB PROGRAMMING

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

Reading 2.2 Cascading Style Sheets

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

Cascading Style Sheet. Styles as Tag Attributes. Syntax. <h1>: what font type/size is used? STYLE = SELECTOR {RULES} Attributes such as bgcolor

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

COSC 2206 Internet Tools. CSS Cascading Style Sheets

CSS.

Media-Specific Styles

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

Cascading Style Sheets Level 2

CSE 154 LECTURE 3: MORE CSS

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

EECS1012. Net-centric Introduction to Computing. Lecture 3: CSS for Styling

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

Introduction to Web Programming and Design

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

CSS Quiz Result. 2) Where in an HTML document is the correct place to refer to an external style sheet?

Creating and Building Websites

Web Technology. Assignment 3. Notes: This assignment is individual assignment, every student should complete it by himself.

CSS for Styling CS380

COMP519 Web Programming Autumn Cascading Style Sheets

Media Types & Media Features

Review Question 1. Which tag is used to create a link to another page? 1. <p> 2. <li> 3. <a> 4. <em>

CSc 337 LECTURE 3: CSS

ICT IGCSE Practical Revision Presentation Web Authoring

CSS Cascading Style Sheets

The Benefits of CSS. Less work: Change look of the whole site with one edit

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

CSS: formatting webpages

Three Ways to Use CSS:

CISC1600-SummerII2012-Raphael-lec3 1

HTMLnotesS15.notebook. January 25, 2015

Introduction to Web Tech and Programming

Shane Gellerman 10/17/11 LIS488 Assignment 3

Activity 4.1: Creating a new Cascading Style Sheet

Web Development & Design Foundations with HTML5

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

How to create and edit a CSS rule

How to lay out a web page with CSS

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

Controlling Appearance the Old Way

Web Development & Design Foundations with HTML5

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

To link to an external stylesheet, the link element is placed within the head of the html page:

Lecture B3 Style : Algorithmic Thinking. Computing and Art : Nature, Power, and Limits CC 3.12: Fall 2007

Using Dreamweaver CS6

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

Taking Fireworks Template and Applying it to Dreamweaver

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Page Layout Using Tables

Introduction to Computer Science Web Development

Styles, Style Sheets, the Box Model and Liquid Layout

CSS. Lecture 16 COMPSCI 111/111G SS 2018

Html basics Course Outline

CS 1100: Web Development: Client Side Coding / Fall 2016 Lab 2: More HTML and CSS

Adding CSS to your HTML

HTML and CSS: An Introduction

Cascading style sheets

CSS 1: Introduction. Chapter 3

Lesson 5 Introduction to Cascading Style Sheets

CSC 443: Web Programming

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

CSS Lecture 16 COMPSCI 111/111G SS 2018

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

Using Dreamweaver CS6

CSS: Cascading Style Sheets

Exam Format: Multiple Choice, True/False, Short Answer (3 points each 75 points total) Write-the-page (25 points)

Scripting for Multimedia LECTURE 5: INTRODUCING CSS3

Web Publishing Intermediate 2

WEBSITE PROJECT 2 PURPOSE: INSTRUCTIONS: REQUIREMENTS:

Overview. Part I: Portraying the Internet as a collection of online information systems HTML/XHTML & CSS

Introduction to Cascading Style Sheet (CSS)

BIM222 Internet Programming

DAY 4. Coding External Style Sheets

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

Introducing Cascading Style Sheets. Cascading Style Sheet Basics Creating Styles Using Styles Manipulating Styles Text Formatting with CSS

Creating and Building Websites

IDM 221. Web Design I. IDM 221: Web Authoring I 1

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

Lab 4 CSS CISC1600, Spring 2012

Transcription:

Web Design Lesson 4 Cascading Style Sheets In the early days of the Web, designers just had the original 91 HTML tags to work with. Using HTML, they could make headings, paragraphs, and basic text formatting, but they didn't have a lot of control over how individual elements in a page would display. Cascading Style Sheets, or CSS, was developed to give designers more control over how the HTML was displayed. CSS allows you to set styles, layout, and formatting much more efficiently than HTML. CSS also allows you to set the styles for a group of pages, or a whole site at once, so that you can easily give all of your pages a consistent look that is easily maintained. Layout and styles can be set using one master CSS file that links to multiple HTML pages. When you want to change something, you can change it in the master style sheet, which will change all of your pages that link to that style sheet. Why do they Cascade? You can set CSS styles in 3 different places on a website: 1. A separate master stylesheet that links to your pages. 2. Styles are embedded in the <head> section of an individual page. 3. Styles can be inserted into an html tag in the lines of code. CSS style rules cascade because the lowest level rule always overrides any other style rules. What this means is that style rules embedded in your HTML tags override rules in the master stylesheet, and in the <head> section of your page. Style rules in the <head> section of your page override any in the master style sheet. There are different reasons to place style rules in each of the three places, but the most common and efficient way to set styles for a website is to have a separate master

stylesheet. That way, you can make changes to just one stylesheet, and those changes will cascade over all pages that link to your main stylesheet. Here is an example of what the code looks like when you link your pages to a master stylesheet-- you can view this same code at the top of all the pages in this course, because they all link to my master stylesheet. The entire head section is copied here, but the important part is in red. <head><meta http-equiv="content-type" content="text/html; charset=iso- 8859-1" /><link type="text/css" rel="stylesheet" href="webdes.css" media="screen" /><title>web Design Lesson 4: Cascading Style Sheets</title> </head> The master stylesheet in the example above is named "webdes.css", and all of the pages in this course link to it. Sometimes you may have a master stylesheet, but you will want one particular page to display a bit differently than the others. You can still have that page link to the master stylesheet, but you can include the individual style rules for that page in the <head> inside an html style tag. In the example below, all of the style rules from the main stylesheet will be followed, except that in this page (and this page only) paragraphs will be in bold font with a red border. <head><meta http-equiv="content-type" content="text/html; charset=iso- 8859-1" /> <link type="text/css" rel="stylesheet" href="webdes.css" media="screen" /> <style> p {font-weight: bold; border: red; } </style> <title>web Design Lesson 4: Cascading Style Sheets</title> </head> You may also want one particular part of a page to display differently. In that case, you would want to embed your style rules directly in your HTML tags. If I wanted that bold font with a red border for just one paragraph, my code would look like the example below:

<p style=font-weight: bold; border: red;>paragraph text goes here</p> Setting style rules Naming a class of an element. CSS allows you to set rules for how HTML elements are displayed. CSS has its own special syntax and ways of setting rules. Here is an example style rule: p.example { width: 50%; margin-left: 15%; border: thin solid red; padding: 1em; font-size: 90%; font-weight: bold; } Click here for an example of what this looks like Above is the style rule for the type of paragraph I'm using for code examples in these lessons. In CSS, you can put a period before a name that you make up, and this will designate a class of element with a specific name; in this case, a paragraph. In my HTML, I can type: <p class="example">, and my page will display the example class of paragraph. My example paragraph has a width of 50% of the page, a left margin of 15%, and a thin red border. The term "padding" refers to the amount of space the browser leaves around an element, in this case, 1em, which is one letter width of white space around all sides of the element. The font size is 90% of the normal font size this browser displays, and the font-weight is bold. Each time I type in <p class="example"> anywhere on my site, this is how the paragraph will be displayed. Setting style rules for an entire page You can also use CSS to control how an entire page displays. For example, here is a style rule for the body of a page: body { font-size: 120%; font-family: Arial, sans-serif; color: green; fontweight: bold; line-height: 200%; background-color: lavender; }

Click here to see how this code will display. All pages that linked to this style rule would display green bold-faced Arial (or sans-serif if the computer did not have Arial) font at 120% of the default size. Text would be doublespaced, and the background color would be lavender. Changing styles mid-line Suppose you had made a class of paragraph like the ones I'm using for my examples, but in one lesson, you wanted to use a normal weight font instead of boldface. A situation like this would be a good time to embed styles directly in your html. Here is how I would change my paragraph example class to have a normal weight font: <p class="example;" style="font-weight: normal;"> By adding the "style" attribute to my tag, I was able to change the font weight to normal, but leave everything else the same. If you wanted to, you could embed all of your styles directly in your HTML like this, but it would be time-consuming and would probably involve a lot of repetitive effort. CSS vs. HTML You can use CSS to control everything about how your page displays. For example, you can use css to control your font size, color, weight, and positioning. You can also use HTML to do some of these things. Newer coding standards encourage CSS for any stylistic decisions, because the content of the page should be separate from how it displays. Below are two examples of styled text, one done with HTML and one done with CSS: I love Paris in the spring!

I love Paris in the spring! The W3C is depreciating, or retiring, HTML tags that have been replaced with CSS, such as the <font> tag, although browsers will still support these tags for at least a few years. Assignment Create a webpage that includes at least one example of each of the following style rules. You may embed your styles in the html or in the head of the document, or you may create an external style sheet. Take a look at the resources page for extra information about CSS. When you finish your page, upload it here and post in the form to let me know you have uploaded it. Your page must display examples of each of the following elements and style rules. There may be ways to do some of these things using HTML tags, but for this assignment, you must use CSS to make these changes. 1. Change the weight of the font. 2. Underline some text. 3. Create a paragraph with a font size that is 50% of the default font size. 4. Create a box with text inside, either by changing the background color for an area, or using a border around an area. 5. Create a link that is red when it hasn't been clicked, and black after it has been clicked. 6. Create a double-spaced list with circle-shaped bullets. 7. Create a heading with a purple sans-serif font. Content Compuhigh.com