Unit 1: Web FundamentalsLesson 7: Introduction to CSS
August 21, 2013
2
Lesson 7: Introduction to 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
Recap of Lessons 1-6 (I)
3
• HTML is very important and is used in everything from websites to email messages to sending data with forms
• HTML files are easy to create – no harder than writing a Word document
Recap of Lessons 1-6 (II)
4
• We can add images and video to our HTML by using tags
• Websites such as YouTube will even give us the HTML code to make embedding content easy
Recap of Lessons 1-6 (III)
5
• Forms help us send information to a server whenever we sign in, search, or post on Facebook
• Meta tags allow us to tell potential visitors what our website is about
• Search engine optimization can help our site rank higher when websites like Google or Yahoo show search results
This is the meta description tag
6
We’ve done HTML – now let’s look at CSS
• We have seen why HTML is important, but CSS is just as useful
• When HTML provides the structure for a page, CSS lets us make it look pretty
HTML is the structure/skeleton
CSS is the presentation/clothing
jQuery/Javascript is the action/movement
7
What would websites look like without CSS? (I)
Facebook Facebook without CSS
8
What would websites look like without CSS? (II)
Pixar Pixar without CSS
9
What would websites look like without CSS? (III)
Google Google without CSS
• Even Google doesn’t look good without CSS!
10
One website can change a LOT when styled with different CSS
• Believe it or not, but the two webpages below were written using identical HTML code
• The only difference between them is in their CSS styling!
11
Restyling the Guardian (I)
1. Last time, we edited the HTML code of the Guardian website. This time, we’ll edit the Guardian’s CSS code. Open up your Chrome web browser and navigate to www.theguardian.com/uk
12
Restyling the Guardian (II)
2. Right click on the white background and click ‘Inspect Element’
‘Inspect Element’
13
Restyling the Guardian (III)
3. Next to the HTML code we looked at last time, you should see a small box in the lower right. Scroll halfway down until you see ‘background-color’
14
Restyling the Guardian (IV)
4. Click the box next to ‘white’, and then select a color in the window that appears
Click here
15
Restyling the Guardian (V)
5. Now the Guardian has a background color!
16
Restyling the Guardian (VI)
6. However, can you guess what happens when we refresh the page?
Refresh
17
Restyling the Guardian (VII)
7. The background color went back to white!
18
How does the internet work – Take #2 (I)
• To understand why our changes disappeared, we need to revisit how the internet works
ISP
Facebook server
Amazon server
Youtube server
DNS
Router
19
How does the internet work – Take #2 (III)
• Originally, we said that the Youtube server was sending Andy Murray the webpage files he requested
• But the server is sending more than just the HTML files – it’s also sending CSS files for the page
Youtube server
HTML
CSS
20
How does the internet work – Take #2 (IV)
• If Andy were to receive just the HTML files, he would see a simple version of the site
HTML
21
How does the internet work – Take #2 (V)
• If Andy were to receive just the HTML files, he would see a simple version of the site
• If he received both HTML and CSS, he would see the full website
HTML
HTML
CSS
22
How does the internet work – Take #2 (VI)
• If Andy were to receive just the HTML files, he would see a simple version of the site
• If he received both HTML and CSS, he would see the full website
• If he only received the CSS files, he would not see the website at all. You cannot add style to a page that has no structure!
HTML
HTML
CSS
CSS
23
Summary (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!
24
Summary (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
25
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