23
Unit 1: Web Fundamentals Lesson 8: Learning to Use CSS August 22, 2013

Lesson 108 23 aug13-1430-ay

Embed Size (px)

Citation preview

Page 1: Lesson 108 23 aug13-1430-ay

Unit 1: Web FundamentalsLesson 8: Learning to Use CSS

August 22, 2013

Page 2: Lesson 108 23 aug13-1430-ay

2

Lesson 8: Learning to Use CSS

Introduction to HTML

Learning to Use HTML

HTML and Email

History and Future of the

Web

HTML and Forms

Search Engine

Optimization

Learning to Use CSS

Introduction to CSS

Reusing Code

3 Ways to Use CSS

Separation of Concerns

Launching Your Own Website

Lesson 1 Lesson 2 Lesson 3 Lesson 4

Lesson 8 Lesson 7 Lesson 6 Lesson 5

Lesson 9 Lesson 10 Lesson 11 Lesson 12

Build understanding Develop skills

Page 3: Lesson 108 23 aug13-1430-ay

3

Recap from last time (I)

• CSS is just as important as HTML because it allows us to style a page to make it look pretty

• Changing the CSS of a site can make a big difference!

Page 4: Lesson 108 23 aug13-1430-ay

4

Recap from last time (II)

• It’s just as easy to edit CSS as it is to revise HTML

• A server actually sends TWO files when you request a webpage – HTML and CSS

• You need both to see the full version of the website

HTML HTML

CSS

Page 5: Lesson 108 23 aug13-1430-ay

5

Let’s write our own CSS file (I)

1. Creating our own CSS file is the same process that we looked at in Lesson 2 for creating an HTML file. If using a PC, open Notepad. If using a Mac, open TextEdit.

MacPC

Page 6: Lesson 108 23 aug13-1430-ay

6

Let’s write our own CSS file (II)

2. Type the following code (make sure to copy it exactly!)

body {background-color: #FFFFF0;color: #FF0000;font-family: copperplate;text-align: center;padding-top: 50px;

}

Page 7: Lesson 108 23 aug13-1430-ay

7

Let’s write our own CSS file (III)

3. Go to ‘File’’Save’ and save the file as ‘smelly-cat.css’.

MacPC

Page 8: Lesson 108 23 aug13-1430-ay

8

Let’s write our own CSS file (IV)

4. Now open your Chrome browser and go to ‘File’’Open File’. Locate our CSS file and open it.

MacPC

Page 9: Lesson 108 23 aug13-1430-ay

9

Let’s write our own CSS file (V)

5. That’s weird…it looks the same as the text we entered. I thought CSS was supposed to look cool!

MacPC

Page 10: Lesson 108 23 aug13-1430-ay

10

Let’s write our own CSS file (VI)

6. Well, remember that you can’t style a webpage using CSS if it doesn’t have an HTML foundation. So now we need to create an HTML file to pair with our CSS file. Let’s open up a new file in Notepad (PC) or TextEdit (Mac).

MacPC

Page 11: Lesson 108 23 aug13-1430-ay

11

Let’s write our own CSS file (VII)

7. Type the following code (make sure there aren’t any typos!)

<html><head></head>

<body><h1>Smelly Cat</h1><h3>By Phoebe Buffay</h3><p>

Smelly Cat, Smelly Cat,<br> What are they feeding you?<br>Smelly Cat, Smelly Cat,<br> It's not your fault.<br>

</p></body></html>

Page 12: Lesson 108 23 aug13-1430-ay

12

Let’s write our own CSS file (VIII)

8. Go to ‘File’‘Save’ and save this file as ‘smelly-cat.html’.

MacPC

Page 13: Lesson 108 23 aug13-1430-ay

13

Let’s write our own CSS file (IX)

9. Open up your Chrome browser again. Go to ‘File’‘Open File’, locate ‘smelly-cat.html’ and open it.

MacPC

Page 14: Lesson 108 23 aug13-1430-ay

14

Let’s write our own CSS file (X)

10. You can see that the content appears, but it hasn’t been stylized at all. This is because our browser doesn’t know that the HTML file and CSS files should be linked together. Let’s link them and see what happens…

MacPC

This address will look different

Page 15: Lesson 108 23 aug13-1430-ay

15

Let’s write our own CSS file (XI)

11. Going back to ‘smelly-cat.html’, add the following line of code between the <head> tags. It should now look like this:

<html><head>

<link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”></head>

<body>…

This line tells the browser to look for a CSS file called “smelly-cat.css”

Page 16: Lesson 108 23 aug13-1430-ay

16

Let’s write our own CSS file (XII)

12. Save “smelly-cat.html” and open it again in the browser. Notice anything different?

MacPC

Page 17: Lesson 108 23 aug13-1430-ay

17

CSS lets us style a page how we want (I)

• Let’s see how just a few lines of CSS code were able to transform the look of our page

Page 18: Lesson 108 23 aug13-1430-ay

18

CSS lets us style a page how we want (II)

body {background-color: #FFFFF0;color: #FF0000;font-family: copperplate;text-align: center;padding-top: 50px;

}

12

• This sets the background color to ‘#FFFFF0’, which is shorthand for pale yellow

• This sets the font color to ‘#FF0000’, which is shorthand for red

• This changes the font style to one named ‘Copperplate’

1

2

3

345

Page 19: Lesson 108 23 aug13-1430-ay

19

CSS lets us style a page how we want (III)

body {background-color: #FFFFF0;color: #FF0000;font-family: copperplate;text-align: center;padding-top: 50px;

}

12

• This aligns the text horizontally in the center of the page

• This adds padding, or extra space, between the text and the top of the page

4

5

345

Page 20: Lesson 108 23 aug13-1430-ay

20

Be creative and use your imagination!

• There are so many possible ways to style a website – you’re limited only by your imagination!

Page 21: Lesson 108 23 aug13-1430-ay

21

Summary (I)

• Creating a CSS file is just as easy as making an HTML file

• CSS always needs to be paired with HTML for the styling to take effect

Page 22: Lesson 108 23 aug13-1430-ay

22

Summary (II)

• The HTML code must tell the browser where to find the matching CSS file

• There are infinite possibilities in styling a website!

Page 23: Lesson 108 23 aug13-1430-ay

23

What to do on your own

1. Go to URL to complete the Codecademy course online

2. Do the practice set on the material learned

3. Take the follow-up quiz to test your understanding