Cascading Style Sheets Part 1 1 IT 130 – Internet and the Web.

Slides:



Advertisements
Similar presentations
HTML popo.
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
CHAPTER 7 STYLING CONTENT WITH CASCADING STYLE SHEETS.
Introduction to CSS.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
XP Introducing Cascading Style Sheets With Cascading Style Sheets (CSS), you can create one or more documents that control the appearance of some or all.
Tutorial 3 Introducing Cascading Style Sheets. XP New Perspectives on Blended HTML, XHTML, and CSS2 Objectives Learn about Cascading Style Sheets Write.
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
4.01 Cascading Style Sheets
Cascading style sheets - CSS
Stylin’ with CSS. 2 Topics What is CSS? Why CSS? CSS Examples.
Using Cascading Style Sheets (CSS) Dept. of Computer Science and Computer Information CSCI N-100.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
1 Web Developer Foundations: Using XHTML Chapter 9 Cascading Style Sheet Concepts.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
STYLING THE WEBSITE - EXTERNAL CSS BY JORGE MARTINEZ.
Cascading style sheets (CSS)
Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
Learning HTML. HTML Attributes HTML elements can have attributes Attributes provide additional information about an element Class – specifies a class.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Css. Definition Cascading style sheet (CSS) Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
Cascade Style Sheet Introduction. What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles were added.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
HTML GUIDE Press F5 and then Click on the links on the left to get to the section you want Section 1: Getting Started Section 2: Moving Banner Section.
Cascading Style Sheets Creating a Uniform Site. Style Sheets  Style sheets are used for conformity on a web page or web site.  Style sheets eliminate.
Cascading Style Sheets
Introduction to CSS. Why CSS? CSS Provides Efficiency in Design and Updates CSS relatively easy to use Can give you more flexibility and control Faster.
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
Introduction to CSS. What is CSS? CSS ("Cascading Style Sheets") determines how the elements in our XHTML documents are displayed and formatted. By using.
Cascading Style Sheets
Practice for Chapter 3: Assume that you are a freelance web designer and need to create a website to promote your freelance company.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Introduction To CSS. Lesson 1: History of CSS CSS was proposed in 1994 as a web styling language. To helps solve some of the problems HTML 4. There were.
CONFIGURING COLOR AND TEXT WITH CSS Chapter 3. Cascading Style Sheets (CSS) Used to configure text, color, and page layout. Launched in 1996 Developed.
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
Internal Style Sheets External Style Sheets
4.01 Cascading Style Sheets
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
>> Introduction to CSS
Cascading Style Sheets Part 1
Introduction to CSS.
Madam Hazwani binti Rahmat
CX Introduction to Web Programming
Web Developer & Design Foundations with XHTML
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
Web Development & Design Foundations with HTML5
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Website Design 3
Introduction to CSS.
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
Introduction to Cascading Style Sheets (CSS)
Tutorial 3 Working with Cascading Style Sheets
Introduction to CSS.
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2016 Terry Ann Morris, Ed.D.
4.01 Cascading Style Sheets
Cascading Style Sheets Part 1
Internal Style Sheets External Style Sheets
Cascading Style Sheets: Part 1
Presentation transcript:

Cascading Style Sheets Part 1 1 IT 130 – Internet and the Web

Learning Objectives After reading/watching/practicing this topic, you should be able to: Name the standards group that developed CSS. – Hint: It’s the same group that in responsible for developing the HTML standard. Name the three components that make up an inline CSS style. Be able to create an inline style. Be able to assign a color to a style using hexadecimal code.

HTML code defines the organization of a document HTML was originally designed so that the tags indicate only the content and organization of a document (headings, lists, titles, etc). It was NOT designed to do the formatting (e.g. bolding, italics, colors, etc). The idea was that the particular web client being used to view the HTML page would apply its own formatting depending on its available fonts, available colors, resolution, and so on. This was fine when the documents were only read by scientists doing research work and nobody was thinking about HTML as being used in the elaborate ways that we see today. 3

…but developers began to want more… As the web became more ubiquitous, the creators of web pages, especially commercial web pages, wanted more control over the formatting of their pages (again: colors, fonts, etc). For this reason, several formatting tags and attributes were introduced in HTML. But many were still unsatisfied with the combination of content and formatting. There were many reasons for this, including limitations on what could be done, and inconsistency in how HTML documents were being displayed among the many different web clients in use. 4

…and then it started getting out of hand… Developers soon started getting carried away though… They started inventing their own HTML formatting tags. Yet most of these tags had not standardized by the W3C which meant that some browsers supported them, and others did not. In addition, because there was no uniformity, even when a tag was “popular” different browsers often displayed the tags differently. All of this went completely against the main objective of HTML which is that a web document should look the same on any browser, on any computer, running any operating system ! A few years ago, the W3C basically decided to start over. They decreed that HTML was no longer to be used for formatting. However, they did come up with a standardized—and quite powerful—way of formatting documents which they called Cascading Style Sheets (CSS). 5

Enter: Cascading Style Sheets (CSS) The W3 Consortium ( the same organization that develops the standards for HTML and XHTML, introduced Cascading Style Sheets in the mid-1990s.  CSS is a new way of formatting web pages.  CSS is designed to augment – not replace — HTML by allowing web designers a powerful and consistent way of formatting web pages. 6

Separating Content and Style The fundamental difference between CSS and HTML, is the distinction between the outline and content of a web page (achieved via HTML) and the style/positioning of that content (achieved via CSS). As we learn about CSS you will see that it provides us with: – Consistent design (e.g. changing a style definition in a single “style sheet” can change every page on your web site!) – More flexibility – Less work to maintain large web sites – some very cool features possible here… Like HTML, style sheets are written in a language with certain rules. We will begin to introduce those rules in this topic. 7

An example of a CSS Style Here is a CSS style that changes the appearance of an h1 tag to double its size and to turn it green: 8 “property” “value” “property”“selector”

Components of a CSS Style The three parts to a CSS style: selector, property, and value. The selector is the HTML tag you are formatting (e.g. H1), The property is the attribute you want to change (e.g. font, color). Each property is set to a value. Every property and its value are separated by a colon ( : ). o Recall that in HTML, we assign an attribute to its value by using the equals sign. However in CSS, we separate a property from its value by a colon. If you include multiple groups of property/value pairs, each group must be separated by semicolons ( ; ). – I typically put a semicolon after every property/value pair. 9

Property / Value Pairs Comparison of how you assign an attribute/property with its value in HTML v.s. CSS: – HTML syntax: attribute="value" – CSS syntax: style="property:value;" 10

Example: Our first CSS style This example applies 3 different styles to a single h1 tag. Note how each property is separated from its value by a colon. Note how each style is separated from the next by a semicolon. <h1 style="font-family:Arial; font-style:italic; font-weight:bold; color:blue;" > 11

Three ways of creating a style: Inline, Internal, External There are 3 different ways that you can apply a CSS style. 1.Inline style 2.Internal (or Embedded) style 3.External style Each has its various advantages. 12

Three ways of creating a style: Inline, Internal, External Inline style – An inline style is applied to a single tag or section of the current HTML file. – Inline style declarations are placed inside the tag. – Internal style sheet (also called embedded style sheet)  discussed later – An internal style is applied to the entire current HTML file but is not applied to other files on the web site. – Internal style declarations are placed in the header of the HTML file. External style sheet (also called linked style sheet)  discussed later – An external style is applied to the entire HTML file and may be applied to any or all pages on the web site. – External style declarations are written in a separate text file which is then linked to the HTML file. – External style sheets make it easy to give a consistent look to any number of web pages. 13

Inline Style For an inline style, the style is declared inside the tag: 14

Inline Style Examples Identify the selector, property, and value body is the selector, color is the property, and blue is the value. This style would set the text of the entire body to blue. body is the selector, background-color is the property, and silver is the value. This style would set the background color of the entire document to silver. 15

Inline Style Examples In the style p is the selector, font-family and font-weight are the properties, and Arial and bold are the values. In the style p is the selector, font-size and color are the properties, and 300% and red are the values. These tags have their usual closing tags. 16

Example This is plain h3 <h3 style="font-family:Arial, Times; font-style:italic; color:green"> This is an example of h3 in Arial, italic, green. 17 This is plain h3 This is h3 in Arial, italic, and green

How to specify colors There are four well-known ways to specify a color. All four examples below specify the color ‘teal’ but in different ways: Name code: body { style= " color: teal " } Hexadecimal form: body {style= " color: # "} – We will use this form – Note the pound sign (#) – this HAS to be there. RGB color values: body {style= " color: rgb(0,128,128) "} RGB color percentages: body {style= " color: rgb(0%,50%,50%) "} Most people use hexadecimal, and that is what we will use in this course. Sometimes during testing, I will use the ‘name code’, (e.g. ‘blue’) but when making a “professional” page, I use hex codes. You should use hex for your assignments. 18

Colors: Names, RGB, and Hex values 19 This is only a very small sampling of the colors available to you. Google “html color swatch” and you’ll see a vast number of pages with similar tables/swatches. One example:

Use Hex codes for your colors! When playing around on your own during testing, experimenting and so on, feel free to use color names. However, when doing “official” work (e.g. homework assignments, quizzes, etc) you should always use hex codes. Happy Grader: … Critical Grader: … 20

Stylin’ with div, and p Tags We’ve seen that you can apply styles within a single tag. Well, what if you applied a style to a ‘p’ or ‘div’ tag? As you might expect, the resulting style would be applied to the entire paragraph (if applied to a ‘p’) or to the entire section (if applied to a ‘div’). All of the content inside this div section would be italicized. Good night… 21