SlideShare una empresa de Scribd logo
1 de 23
Unit 1: Web Fundamentals
Lesson 9: Separation of Concerns
August 23, 2013
Lesson 9: Separation of Concerns
2
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 from last time (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
3
Recap from last time (II)
• The HTML code must tell the browser where to find the matching
CSS file
• There are infinite possibilities in styling a website!
4
Why do we do it this way?
• We’ve already learned how to write our own HTML and CSS files
and link them together
• But why do we need TWO sets of code? Wouldn’t it be easier to just
combine the two files into one?
5
Why do we separate HTML and CSS?
1. Saves time by reusing code
2. Helps us debug our code
1. Keeps us organized
6
Reusing code saves a lot of time! (I)
• We saw in Lesson 8 that we had to include a line of code in our
HTML to link it with our CSS file
7
<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”
Reusing code saves a lot of time! (II)
• But what if we had two HTML pages that we wanted to style the
same way? Would we need a second CSS file?
• Nope. All we have to do is include the same line of code in both
HTML files to tell the browser where to find the one CSS file to use
8
<html>
<head>
<link rel=“stylesheet”
type=“text/css” href=“smelly-
cat.css”>
</head>
<body>
…
<html>
<head>
<link rel=“stylesheet”
type=“text/css” href=“smelly-
cat.css”>
</head>
<body>
… HTML file #1 HTML file #2
Reusing code saves a lot of time! (III)
• Now imagine that instead of two HTML files, we had 100 of them
• Being able to link them all to the same CSS file saves us from
having to write 99 more CSS files!
9
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“smelly-cat.css”>
</head>
<body>
…
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“smelly-cat.css”>
</head>
<body>
…
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“smelly-cat.css”>
</head>
<body>
…
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“smelly-cat.css”>
</head>
<body>
…
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“smelly-cat.css”>
</head>
<body>
…
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“smelly-cat.css”>
</head>
<body>
…
<html>
<head>
<link rel=“stylesheet” type=“text/css”
href=“smelly-cat.css”>
</head>
<body>
…
HTML file #1 HTML file #2 HTML file #3 HTML file #4
HTML file #5 HTML file #6 HTML file #7
. . .
Reusing code saves a lot of time! (IV)
• Most websites have more than one page but want to keep the same
theme across all pages, so they are often reusing CSS code
• They can share font styles, background colors, font sizes, and many
other elements
10
www.codecademy.com www.codecademy.com/about
Both pages share the same navigation bar,
and probably the same CSS stylesheet!
Why do we separate HTML and CSS?
1. Saves time by reusing code
2. Helps us debug our code
1. Keeps us organized
11
Everyone makes mistakes (I)
• No one is perfect – when we make mistakes while coding, our
website won’t look the way we want.
• We then need to debug, or find and fix mistakes in our code
• But sometimes, it’s obvious that something is wrong with your
website, but you can’t find the error in your code
12
Everyone makes mistakes (II)
• To find errors more quickly, we need to make sure our code is easy
to read and review
• If we combined our HTML and CSS files into one, it would become a
lot harder to debug!
• Combining the two results in code bloat, big and messy code that’s
difficult to read
13
Everyone makes mistakes (III)
14
<html>
<head>
</head>
<body>
<p>Avoid code bloat!</p>
</body>
</html>
body {
text-align: center;
p {color: red;}
}
<html>
<head>
<style type=“text/css”>
body {text-align: center;}
</style>
</head>
<body>
<p style=“color: red;”>
Avoid code bloat!
</p>
</body>
</html>
HTML mixed with CSS HTML only
CSS only
This is code bloat!
Everyone makes mistakes (IV)
• Remember that code is read many times, but written only once
• Since code is read every time you review, debug, or share files with
others, we need to make sure it’s easy to read!
15
Avoiding code bloat makes code easier to read!
Why do we separate HTML and CSS?
1. Saves time by reusing code
2. Helps us debug our code
1. Keeps us organized
16
Separation of concerns (I)
• We’ve seen how avoiding code bloat helps in debugging our code
• It also helps to divide our code into multiple sections that each focus
on different areas – this is known as separation of concerns
• This is why it makes sense to split HTML and CSS into two files –
HTML focuses on the structure of the page while CSS affects its
presentation
17
Separation of concerns (I)
• Dividing our code into two files also makes it easier for us to work on
them with others
• One person can focus on changing the HTML structure while
another can work on the CSS styling
• If it were combined into a single file, version control would be much
harder – it would be more difficult to keep track of the changes
everyone was making!
18
Separation of concerns (III)
19
Header
Footer
Signup form
Login form
• We apply this principle not just to dividing HTML from CSS, but to all
the code we write!
• For example, you may want to separate the sections of your code
that describe your website’s header, footer, login, and signup
Summary (I)
• It’s important to divide our HTML pages from our CSS files
1. It saves us time by reusing code. We can link multiple HTML
pages with a single CSS stylesheet.
20
www.codecademy.com www.codecademy.com/about
Both pages share the same navigation bar,
and probably the same CSS stylesheet!
Summary (II)
2. It helps us debug our code. By keeping the files separate, it
makes our code easier to read, which helps us find our mistakes.
21
<html>
<head>
</head>
<body>
<p>Avoid code bloat!</p>
</body>
</html>
body {
text-align: center;
p {color: red;}
}
<html>
<head>
<style type=“text/css”>
body {text-align: center;}
</style>
</head>
<body>
<p style=“color: red;”>
Avoid code bloat!
</p>
</body>
</html>
HTML mixed with CSS HTML only
CSS only
This is code bloat!
Summary (III)
3. It keeps us organized. Separation of concerns splits our code into
sections, which helps us to work together in teams.
22
Header
Footer
Signup form
Login form
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
1. Take the follow-up quiz to test your understanding
23

Más contenido relacionado

La actualidad más candente

Webware - from Document to Operating System
Webware - from Document to Operating System Webware - from Document to Operating System
Webware - from Document to Operating System
Channy Yun
 
[Access U 2010] HTML5 & Accessibility
[Access U 2010] HTML5 & Accessibility[Access U 2010] HTML5 & Accessibility
[Access U 2010] HTML5 & Accessibility
Christopher Schmitt
 
HTML CSS Best Practices
HTML CSS Best PracticesHTML CSS Best Practices
HTML CSS Best Practices
hoctudau
 
Lecture1: HTML and JavaScript
Lecture1: HTML and JavaScriptLecture1: HTML and JavaScript
Lecture1: HTML and JavaScript
omarshehab
 

La actualidad más candente (20)

Introduction to HTML5+CSS
Introduction to HTML5+CSSIntroduction to HTML5+CSS
Introduction to HTML5+CSS
 
Training HTML5 CSS3 Ilkom IPB
Training HTML5 CSS3 Ilkom IPBTraining HTML5 CSS3 Ilkom IPB
Training HTML5 CSS3 Ilkom IPB
 
Html and css
Html and cssHtml and css
Html and css
 
Front End Best Practices
Front End Best PracticesFront End Best Practices
Front End Best Practices
 
HTML CSS and Web Development
HTML CSS and Web DevelopmentHTML CSS and Web Development
HTML CSS and Web Development
 
Html & CSS
Html & CSSHtml & CSS
Html & CSS
 
HTML and CSS
HTML and CSSHTML and CSS
HTML and CSS
 
Webware - from Document to Operating System
Webware - from Document to Operating System Webware - from Document to Operating System
Webware - from Document to Operating System
 
Html css java script basics All about you need
Html css java script basics All about you needHtml css java script basics All about you need
Html css java script basics All about you need
 
[Access U 2010] HTML5 & Accessibility
[Access U 2010] HTML5 & Accessibility[Access U 2010] HTML5 & Accessibility
[Access U 2010] HTML5 & Accessibility
 
CSS Frameworks
CSS FrameworksCSS Frameworks
CSS Frameworks
 
Html & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshopHtml & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshop
 
HTML CSS Best Practices
HTML CSS Best PracticesHTML CSS Best Practices
HTML CSS Best Practices
 
Artdm171 Week4 Tags
Artdm171 Week4 TagsArtdm171 Week4 Tags
Artdm171 Week4 Tags
 
Lecture1: HTML and JavaScript
Lecture1: HTML and JavaScriptLecture1: HTML and JavaScript
Lecture1: HTML and JavaScript
 
HTML5 & CSS3
HTML5 & CSS3 HTML5 & CSS3
HTML5 & CSS3
 
Intro to HTML & CSS
Intro to HTML & CSSIntro to HTML & CSS
Intro to HTML & CSS
 
HTML & CSS 2017
HTML & CSS 2017HTML & CSS 2017
HTML & CSS 2017
 
Chapter4
Chapter4Chapter4
Chapter4
 
Twitter bootstrap training_session_ppt
Twitter bootstrap training_session_pptTwitter bootstrap training_session_ppt
Twitter bootstrap training_session_ppt
 

Destacado

Lesson 205 07 oct13-1500-ay
Lesson 205 07 oct13-1500-ayLesson 205 07 oct13-1500-ay
Lesson 205 07 oct13-1500-ay
Codecademy Ren
 
Lesson 204 03 oct13-1500-ay
Lesson 204 03 oct13-1500-ayLesson 204 03 oct13-1500-ay
Lesson 204 03 oct13-1500-ay
Codecademy Ren
 
Lesson 303 05 jan14-1500-ay
Lesson 303 05 jan14-1500-ayLesson 303 05 jan14-1500-ay
Lesson 303 05 jan14-1500-ay
Codecademy Ren
 
Lesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayLesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ay
Codecademy Ren
 
Lesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ayLesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ay
Codecademy Ren
 
Lesson 102 23 aug13-1430-ay
Lesson 102 23 aug13-1430-ayLesson 102 23 aug13-1430-ay
Lesson 102 23 aug13-1430-ay
Codecademy Ren
 
Lesson 304 05 jan14-1500-ay
Lesson 304 05 jan14-1500-ayLesson 304 05 jan14-1500-ay
Lesson 304 05 jan14-1500-ay
Codecademy Ren
 
Lesson 302 05 jan14-1500-ay
Lesson 302 05 jan14-1500-ayLesson 302 05 jan14-1500-ay
Lesson 302 05 jan14-1500-ay
Codecademy Ren
 
Lesson 105 23 aug13-1430-ay
Lesson 105 23 aug13-1430-ayLesson 105 23 aug13-1430-ay
Lesson 105 23 aug13-1430-ay
Codecademy Ren
 
Lesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ayLesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ay
Codecademy Ren
 

Destacado (10)

Lesson 205 07 oct13-1500-ay
Lesson 205 07 oct13-1500-ayLesson 205 07 oct13-1500-ay
Lesson 205 07 oct13-1500-ay
 
Lesson 204 03 oct13-1500-ay
Lesson 204 03 oct13-1500-ayLesson 204 03 oct13-1500-ay
Lesson 204 03 oct13-1500-ay
 
Lesson 303 05 jan14-1500-ay
Lesson 303 05 jan14-1500-ayLesson 303 05 jan14-1500-ay
Lesson 303 05 jan14-1500-ay
 
Lesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayLesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ay
 
Lesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ayLesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ay
 
Lesson 102 23 aug13-1430-ay
Lesson 102 23 aug13-1430-ayLesson 102 23 aug13-1430-ay
Lesson 102 23 aug13-1430-ay
 
Lesson 304 05 jan14-1500-ay
Lesson 304 05 jan14-1500-ayLesson 304 05 jan14-1500-ay
Lesson 304 05 jan14-1500-ay
 
Lesson 302 05 jan14-1500-ay
Lesson 302 05 jan14-1500-ayLesson 302 05 jan14-1500-ay
Lesson 302 05 jan14-1500-ay
 
Lesson 105 23 aug13-1430-ay
Lesson 105 23 aug13-1430-ayLesson 105 23 aug13-1430-ay
Lesson 105 23 aug13-1430-ay
 
Lesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ayLesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ay
 

Similar a Lesson 109 23 aug13-1430-ay

Lesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ayLesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ay
Codecademy Ren
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
Lesson 111 24 aug13-1430-ay
Lesson 111 24 aug13-1430-ayLesson 111 24 aug13-1430-ay
Lesson 111 24 aug13-1430-ay
Codecademy Ren
 
Lesson 206 11 oct13-1500-ay
Lesson 206 11 oct13-1500-ayLesson 206 11 oct13-1500-ay
Lesson 206 11 oct13-1500-ay
Codecademy Ren
 
Lesson 112 24 aug13-2300-ay
Lesson 112 24 aug13-2300-ayLesson 112 24 aug13-2300-ay
Lesson 112 24 aug13-2300-ay
Codecademy Ren
 
Html:css crash course (4:5)
Html:css crash course (4:5)Html:css crash course (4:5)
Html:css crash course (4:5)
Thinkful
 

Similar a Lesson 109 23 aug13-1430-ay (20)

Lesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ayLesson 108 23 aug13-1430-ay
Lesson 108 23 aug13-1430-ay
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
 
Lesson 111 24 aug13-1430-ay
Lesson 111 24 aug13-1430-ayLesson 111 24 aug13-1430-ay
Lesson 111 24 aug13-1430-ay
 
Htmlcss1
Htmlcss1Htmlcss1
Htmlcss1
 
Le wagon workshop - 2h landing page - Andre Ferrer
Le wagon   workshop - 2h landing page - Andre FerrerLe wagon   workshop - 2h landing page - Andre Ferrer
Le wagon workshop - 2h landing page - Andre Ferrer
 
HTML.pptx
HTML.pptxHTML.pptx
HTML.pptx
 
Lesson 206 11 oct13-1500-ay
Lesson 206 11 oct13-1500-ayLesson 206 11 oct13-1500-ay
Lesson 206 11 oct13-1500-ay
 
Lesson 112 24 aug13-2300-ay
Lesson 112 24 aug13-2300-ayLesson 112 24 aug13-2300-ay
Lesson 112 24 aug13-2300-ay
 
Thinkful - Frontend Crash Course - Intro to HTML/CSS
Thinkful - Frontend Crash Course - Intro to HTML/CSSThinkful - Frontend Crash Course - Intro to HTML/CSS
Thinkful - Frontend Crash Course - Intro to HTML/CSS
 
Website development-osgl
Website development-osglWebsite development-osgl
Website development-osgl
 
HTML course.ppt
HTML course.pptHTML course.ppt
HTML course.ppt
 
Intro To Twitter Bootstrap
Intro To Twitter BootstrapIntro To Twitter Bootstrap
Intro To Twitter Bootstrap
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
 
Web development using HTML and CSS
Web development using HTML and CSSWeb development using HTML and CSS
Web development using HTML and CSS
 
Pertemuan 7
Pertemuan 7Pertemuan 7
Pertemuan 7
 
Lecture2 CSS1
Lecture2  CSS1Lecture2  CSS1
Lecture2 CSS1
 
lesson-1-introduction-html-and-css.pptx
lesson-1-introduction-html-and-css.pptxlesson-1-introduction-html-and-css.pptx
lesson-1-introduction-html-and-css.pptx
 
Introduction to html course digital markerters
Introduction to html course digital markertersIntroduction to html course digital markerters
Introduction to html course digital markerters
 
Html:css crash course (4:5)
Html:css crash course (4:5)Html:css crash course (4:5)
Html:css crash course (4:5)
 

Más de Codecademy Ren

Lesson 301 26 nov13-1500-ay
Lesson 301 26 nov13-1500-ayLesson 301 26 nov13-1500-ay
Lesson 301 26 nov13-1500-ay
Codecademy Ren
 
Lesson 207 19 oct13-1500-ay
Lesson 207 19 oct13-1500-ayLesson 207 19 oct13-1500-ay
Lesson 207 19 oct13-1500-ay
Codecademy Ren
 
Lesson 106 23 aug13-1430-ay
Lesson 106 23 aug13-1430-ayLesson 106 23 aug13-1430-ay
Lesson 106 23 aug13-1430-ay
Codecademy Ren
 
Lesson 102 25 aug13-2200-ay
Lesson 102 25 aug13-2200-ayLesson 102 25 aug13-2200-ay
Lesson 102 25 aug13-2200-ay
Codecademy Ren
 
Lesson 103 23 aug13-1430-ay
Lesson 103 23 aug13-1430-ayLesson 103 23 aug13-1430-ay
Lesson 103 23 aug13-1430-ay
Codecademy Ren
 
Lesson 104 23 aug13-1430-ay
Lesson 104 23 aug13-1430-ayLesson 104 23 aug13-1430-ay
Lesson 104 23 aug13-1430-ay
Codecademy Ren
 

Más de Codecademy Ren (6)

Lesson 301 26 nov13-1500-ay
Lesson 301 26 nov13-1500-ayLesson 301 26 nov13-1500-ay
Lesson 301 26 nov13-1500-ay
 
Lesson 207 19 oct13-1500-ay
Lesson 207 19 oct13-1500-ayLesson 207 19 oct13-1500-ay
Lesson 207 19 oct13-1500-ay
 
Lesson 106 23 aug13-1430-ay
Lesson 106 23 aug13-1430-ayLesson 106 23 aug13-1430-ay
Lesson 106 23 aug13-1430-ay
 
Lesson 102 25 aug13-2200-ay
Lesson 102 25 aug13-2200-ayLesson 102 25 aug13-2200-ay
Lesson 102 25 aug13-2200-ay
 
Lesson 103 23 aug13-1430-ay
Lesson 103 23 aug13-1430-ayLesson 103 23 aug13-1430-ay
Lesson 103 23 aug13-1430-ay
 
Lesson 104 23 aug13-1430-ay
Lesson 104 23 aug13-1430-ayLesson 104 23 aug13-1430-ay
Lesson 104 23 aug13-1430-ay
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Lesson 109 23 aug13-1430-ay

  • 1. Unit 1: Web Fundamentals Lesson 9: Separation of Concerns August 23, 2013
  • 2. Lesson 9: Separation of Concerns 2 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
  • 3. Recap from last time (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 3
  • 4. Recap from last time (II) • The HTML code must tell the browser where to find the matching CSS file • There are infinite possibilities in styling a website! 4
  • 5. Why do we do it this way? • We’ve already learned how to write our own HTML and CSS files and link them together • But why do we need TWO sets of code? Wouldn’t it be easier to just combine the two files into one? 5
  • 6. Why do we separate HTML and CSS? 1. Saves time by reusing code 2. Helps us debug our code 1. Keeps us organized 6
  • 7. Reusing code saves a lot of time! (I) • We saw in Lesson 8 that we had to include a line of code in our HTML to link it with our CSS file 7 <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”
  • 8. Reusing code saves a lot of time! (II) • But what if we had two HTML pages that we wanted to style the same way? Would we need a second CSS file? • Nope. All we have to do is include the same line of code in both HTML files to tell the browser where to find the one CSS file to use 8 <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly- cat.css”> </head> <body> … <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly- cat.css”> </head> <body> … HTML file #1 HTML file #2
  • 9. Reusing code saves a lot of time! (III) • Now imagine that instead of two HTML files, we had 100 of them • Being able to link them all to the same CSS file saves us from having to write 99 more CSS files! 9 <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”> </head> <body> … <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”> </head> <body> … <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”> </head> <body> … <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”> </head> <body> … <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”> </head> <body> … <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”> </head> <body> … <html> <head> <link rel=“stylesheet” type=“text/css” href=“smelly-cat.css”> </head> <body> … HTML file #1 HTML file #2 HTML file #3 HTML file #4 HTML file #5 HTML file #6 HTML file #7 . . .
  • 10. Reusing code saves a lot of time! (IV) • Most websites have more than one page but want to keep the same theme across all pages, so they are often reusing CSS code • They can share font styles, background colors, font sizes, and many other elements 10 www.codecademy.com www.codecademy.com/about Both pages share the same navigation bar, and probably the same CSS stylesheet!
  • 11. Why do we separate HTML and CSS? 1. Saves time by reusing code 2. Helps us debug our code 1. Keeps us organized 11
  • 12. Everyone makes mistakes (I) • No one is perfect – when we make mistakes while coding, our website won’t look the way we want. • We then need to debug, or find and fix mistakes in our code • But sometimes, it’s obvious that something is wrong with your website, but you can’t find the error in your code 12
  • 13. Everyone makes mistakes (II) • To find errors more quickly, we need to make sure our code is easy to read and review • If we combined our HTML and CSS files into one, it would become a lot harder to debug! • Combining the two results in code bloat, big and messy code that’s difficult to read 13
  • 14. Everyone makes mistakes (III) 14 <html> <head> </head> <body> <p>Avoid code bloat!</p> </body> </html> body { text-align: center; p {color: red;} } <html> <head> <style type=“text/css”> body {text-align: center;} </style> </head> <body> <p style=“color: red;”> Avoid code bloat! </p> </body> </html> HTML mixed with CSS HTML only CSS only This is code bloat!
  • 15. Everyone makes mistakes (IV) • Remember that code is read many times, but written only once • Since code is read every time you review, debug, or share files with others, we need to make sure it’s easy to read! 15 Avoiding code bloat makes code easier to read!
  • 16. Why do we separate HTML and CSS? 1. Saves time by reusing code 2. Helps us debug our code 1. Keeps us organized 16
  • 17. Separation of concerns (I) • We’ve seen how avoiding code bloat helps in debugging our code • It also helps to divide our code into multiple sections that each focus on different areas – this is known as separation of concerns • This is why it makes sense to split HTML and CSS into two files – HTML focuses on the structure of the page while CSS affects its presentation 17
  • 18. Separation of concerns (I) • Dividing our code into two files also makes it easier for us to work on them with others • One person can focus on changing the HTML structure while another can work on the CSS styling • If it were combined into a single file, version control would be much harder – it would be more difficult to keep track of the changes everyone was making! 18
  • 19. Separation of concerns (III) 19 Header Footer Signup form Login form • We apply this principle not just to dividing HTML from CSS, but to all the code we write! • For example, you may want to separate the sections of your code that describe your website’s header, footer, login, and signup
  • 20. Summary (I) • It’s important to divide our HTML pages from our CSS files 1. It saves us time by reusing code. We can link multiple HTML pages with a single CSS stylesheet. 20 www.codecademy.com www.codecademy.com/about Both pages share the same navigation bar, and probably the same CSS stylesheet!
  • 21. Summary (II) 2. It helps us debug our code. By keeping the files separate, it makes our code easier to read, which helps us find our mistakes. 21 <html> <head> </head> <body> <p>Avoid code bloat!</p> </body> </html> body { text-align: center; p {color: red;} } <html> <head> <style type=“text/css”> body {text-align: center;} </style> </head> <body> <p style=“color: red;”> Avoid code bloat! </p> </body> </html> HTML mixed with CSS HTML only CSS only This is code bloat!
  • 22. Summary (III) 3. It keeps us organized. Separation of concerns splits our code into sections, which helps us to work together in teams. 22 Header Footer Signup form Login form
  • 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 1. Take the follow-up quiz to test your understanding 23