Adding CSS to HTML, online
Six activities your students do on their own devices. See who's finished, and their scores.
Adding CSS to HTML in one minute
What students need to know
Linking one external file from many pages means a single change updates every page at once. <link rel="stylesheet" href="file.css"> in the <head> loads an external CSS file. <css> is not a valid HTML element.
<link> and <style> both belong in the <head>. Placing them in <body> is invalid and may cause rendering issues. Inline styles (style="...") override external and embedded styles because they have the highest specificity.
Mistakes students make
- HTML tag names must be lowercase. <Style> should be written as <style>.
- The href attribute value must be in double quotes: href="styles.css", not href=styles.css without quotes.
- The rel attribute value must be in double quotes: rel="stylesheet", not rel=stylesheet without quotes.
- HTML tag names must be lowercase. </Style> should be written as </style>.
What students will learn in this module
Every question in Module 33
Quick questions
- Which element connects an external CSS file to an HTML page?A<link>B<css>
- Where must <link> and <style> elements be placed?AInside the <body> elementBInside the <head> element
- Which CSS method has the highest specificity?AInline style attributeBExternal stylesheet
- True or false: the rel attribute on <link> must be 'stylesheet' to load CSS.ATrueBFalse
- Which approach is best for styling multiple HTML pages consistently?AInline style attribute on each elementBExternal stylesheet with <link>
Key terms
Students type the meaning of:
<link>
Match the pairs
<link rel="stylesheet" href="main.css">Match it to what it does<p style="color: red;">Hello</p>Match it to what it doesExternal stylesheets are preferred — one CSS file can be shared across multiple HTML pagesMatch it to what it does<style> in <head> embeds CSS rules directly inside the HTML documentMatch it to what it does<Style>
p { color: blue; }
</Style>Match it to what it does<link rel="stylesheet">Match it to what it doesFill in the blanks
<_____> p { color: red; } </style>Hint: Type the element name that embeds CSS directly inside the HTML document
<____ rel="stylesheet" href="main.css">
Hint: Type the self-closing element name used to attach an external CSS file
<link rel="__________" href="app.css">
Hint: Type the rel value that tells the browser this linked file is a CSS stylesheet
<link rel="stylesheet" ____="style.css">
Hint: Type the attribute name on link that provides the path to the CSS file
<p _____="color: blue;">Hello</p>
Hint: Type the attribute name used to apply CSS directly to a single element
Spot the error
Question 1
A<Style>B p { color: red; }C</style>
Question 2
A<head>B <link rel="stylesheet" href=styles.css>C <title>My Page</title>D</head>
Question 3
A<head>B <title>Page</title>C <link rel=stylesheet href="main.css">D</head>
Question 4
A<head>B <title>Page</title>C <style>D </Style>E</head>
Question 5
A<html>B<head><title>Page</title></head>C<body>D <p style=color:red>Hello</p>E</body>F</html>
