css basics - roosevelt cs & web designcss basics 2 what is css ? ... what is css ? it is not the...

22
CSS Basics 1

Upload: others

Post on 19-Apr-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

1

Page 2: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

2

What is CSS ?Why use CSS ?How does it work ?

Page 3: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

3

What is CSS ?

It is NOT the same as HTMLIt is a different language (code)It is more complex than HTML

Page 4: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

4

What is CSS ?

A language for specifying appearanceSeparate FORM from CONTENTHTML for the content (data)CSS for the form (presentation)

Page 5: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

5

Content

<body> … </body><p> Lots of text </p><h1> Titles </h1><img src=”picture.jpg” /><ol> … </ol><div> … </div>etc.

Data/Structurecolor:green;margin:20px;padding:5px;border:2px solid black;background:yellow;font-weight:bold;etc.

Visual Style

Form vs

Page 6: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

6

<body> … </body><p> Lots of text </p><h1> Titles </h1><img src=”picture.jpg” /><ol> … </ol><div> … </div>etc.

HTMLcolor:green;margin:20px;padding:5px;border:2px solid black;background:yellow;font-weight:bold;etc.

CSS

Content Form vs

Page 7: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

7

Why use CSS ?

More powerful for controlling visuals than HTMLMore efficient for browsers than HTMLMore flexible for complex sites

Page 8: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

8

Why use CSS ?

Separation of CONTENT and FORM is importantEasily change the look without touching the contentDifferent people do those jobs

Page 9: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

9

Why use CSS ?

http://www.csszengarden.com/

Page 10: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

10

How does CSS work ?

Define a style specificationApply it to HTML elements

<body style="background:goldenrod;">

Page 11: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

11

How does CSS work ?

Inline stylesInternal style sheetsExternal style sheets

3 Methods

Page 12: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

12

Inline styles

<body style="background:goldenrod;"><hr style="height:3px;background-color:dimgray;"><ul style="list-style-image:url('cd-bullet.png');"><div style="background:yellow; margin:20px;}">

Page 13: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

13

But ...

What if you had 100<div style=”…”>boxes</div>

that you wanted to restyle ???

Page 14: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

14

Internal style sheets<head> <title>Davidson @ RHS</title> <style> body {background:goldenrod;} hr {height:3px;background-color:dimgray;} ul {list-style-image:url('cd-bullet.png');} div {background:yellow; margin:20px;} </style></head>

Page 15: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

15

Internal style sheets <style> body {background:goldenrod;} hr {height:3px; background-color:dimgray;} ul {list-style-image:url('cd-bullet.png');} div {background:yellow; margin:20px;} </style>These apply to ALL occurrences of the HTML element on the page.

Page 16: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

16

But ...

What if you want to apply different styles to

different occurrences of an element on the page ???

Page 17: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

17

<div>!<p>Today some very misguided person set a fire in one of the bathrooms at school. This was not a good thing, by any means. But it spawned a wonderful, impromptu assembly in the gym while we waited to go back to classes.</p>

</div>

<div>!<p>I played some of one version of "Hallelujah" in my classes today and was pleasantly surprised to see that many of my students responded to it and know it from some recent popular culture appearances.</p>

</div>

For instance ...

Page 18: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

18

<style> div {background:yellow; margin:20px;} </style>

Using this style definition would make all of the <div>s have yellow backgrounds.

Page 19: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

19

There is a way...

We can give different names to different styles, and apply them to different occurrences

of an element.

Page 20: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

20

CSS Classeselement.class

<style>div.bright {background:yellow;}div.neon {background:green;}

</style>

<div class="bright"><div class="neon">

Page 21: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

21

<div class="bright">!<p>Today some very misguided person set a fire in one of the bathrooms at school. This was not a good thing, by any means. But it spawned a wonderful, impromptu assembly in the gym while we waited to go back to classes.</p>

</div>

<div class="neon">!<p>I played some of one version of "Hallelujah" in my classes today and was pleasantly surprised to see that many of my students responded to it and know it from some recent popular culture appearances.</p>

</div>

<style>div.bright {background:yellow; margin:20px;}div.neon {background:green; margin:20px;}

</style>

Page 22: CSS Basics - Roosevelt CS & Web DesignCSS Basics 2 What is CSS ? ... What is CSS ? It is NOT the same as HTML It is a different language (code) It is more complex than HTML. CSS Basics

CSS Basics

22

Internal style sheets

Blog Page Example