web workshop: css objectives: - “what is css?” - structure of css - how to use css in your...

22
Web Workshop: CSS Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

Post on 20-Dec-2015

236 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

Web Workshop: CSSWeb Workshop: CSS

Objectives:

- “What is CSS?”

- Structure of CSS

- How to use CSS in your webpage

Page 2: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

What is CSS? (1)What is CSS?

CSS stands for “Cascading Style Sheets”

Cascading: refers to the procedure that determines which style will apply to a certain section, if you have more than one style rule.

Page 3: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

What is CSS? (2)What is CSS?

CSS stands for “Cascading Style Sheets”

Style: how you want a certain part of your page to look. You can set things like color, margins, font, etc for things like tables, paragraphs, and headings.

Page 4: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

What is CSS? (3)What is CSS?

CSS stands for “Cascading Style Sheets”

Sheets: the “sheets” are like templates, or a set of rules, for determining how the webpage will look.

Page 5: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

What is CSS? (4) What is CSS?

So, CSS (all together) is a styling language – a set of rules to tell browsers how your webpage should look.

Page 6: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

What is “Style”?What is “Style”

“Style” is a command that you set to tell the browser how a certain section of your webpage should look.

You can use style on many HTML “elements”

(like <p> <h1> <table> etc)

Page 7: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

How to write style rules (1)How to write style rules

Two parts: (1) selector and (2) declaration.

Selector: the HTML element you want to add style to.

<p> <h1> <table> etc

Declaration: the statement of style for that element. Made up of property and value.

Page 8: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

How to write style rules (2)How to write style rules

Selector {declaration;}

Declaration = {property: value;}

Property: what aspect you want to change

ex: color, font, margins, etc.

Value: the exact setting for that aspect.

ex: red, italic, 40px, etc.

Page 9: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

How to write style rules (2)How to write style rules

selector {property: value;}

Essentially means:

The thing I want to change

{the aspect of that thing I want to change: what I want it to be;}

Page 10: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

How to write style rules (3)How to write style rules

Selector {property: value;}

h1 {color: red;}

Means: Speaking of my heading1, I want the text color to be red.

Page 11: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

How to write style rules (3)How to write style rules

Selector {property: value;}

I want the color of the text in my paragraph to be yellow.

p {color: yellow;}

This is the text in this paragraph.

Page 12: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

How to write style rules (4)How to write style rules

Selector {property: value;}

h1 {color: blue;background-color: green;}

Means: Speaking of my heading1, I want the text

color to be blue and the background color to be green.

Page 13: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

How to write style rules (4)How to write style rules

Selector {property: value;}

I want the text color of my link to be red and the background color to be yellow.

a {color: red;background-color: yellow;}

This is my link

Page 14: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

Three types of styleWhere do I put my style rules?

There are three types of style-rule-places that we will cover:

- Inlined - Internal Style Sheet - External Style Sheet

Page 15: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

<html>

<head><title>My Wonderful Example</title>

</head>

<body>

<p>What was I thinking?</p>

</body>

</html>

a) Inlined example-1

Original html code

Page 16: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

a) Inlined example-2

<body>

<p style=“text-align: center; font-weight: bold; color: yellow;”>What was I thinking?</p>

</body>

What was I thinking?

Page 17: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

<head><title>My Wonderful Example</title> <style type=“text/css”> body {

text-align: left;font-family: trebuchet, verdana;}

</style></head>

b) Internal-1

Page 18: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

b) Internal-2

<head><title>My Wonderful Example</title> <style type=“text/css”> body

{text-align: left; font-family: Trebuchet, verdana;}

</style></head>

Page 19: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

Internal: Statement of style

<style type=“text/css”>…</style>

this is a style sheet (style type) written (text) in

css (CSS) language

Page 20: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

Internal: Brackets & Declaration

<style type=“text/css”>body

{text-align: left;font-family: trebuchet, verdana;}

</style>

I want the “align text” property to be given the value of

“left”

Page 21: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

c) External

<html><head><title>My Way</title>

<link rel="stylesheet" href="http://www2.hawaii.edu/~myway.

css" type="text/css“></head><body> </body></html> Link to a

separate css page

Page 22: Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage

The end of Basic CSS

On to the exercises!