REVIEW
Can you spot all the errors in this block of code?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Syntax Review</title>
</head>
<h1>Hello World!</h1>
<body>
<h2>There are errors in this code</h2>
<a href=https://youtube.com">Something isn't right...</a>
<li>Can you find all the errors?</li>
<li>Write down as many as you can find.</li>
<li>You got this!</li>
<p>Do you see <em>what's wrong here?</p></em>
<h2>Dog picture:</h3>
<img href="images/puppy.jpg" />
</body>
</html>
REVIEW
Can you spot all the errors in this block of code?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Syntax Review</title>
</head>
<h1>Hello World!</h1>
<body>
<h2>There are errors in this code</h2>
<a href=https://youtube.com">Something isn't right...</a>
<li>Can you find all the errors?</li>
<li>Write down as many as you can find.</li>
<li>You got this!</li>
<p>Do you see <em>what's wrong here?</p></em>
<h2>Dog picture:</h3>
<img href="images/puppy.jpg" />
</body>
</html>
CSS Foundations
CSS Foundations
CSS Foundations
CSS Foundations
CSS Foundations
Three ways:
CSS Foundations
Used to style a single HTML element using the style attribute
<h1 style="color: red;">Using inline styles</h1>CSS Foundations
Used to style a single HTML element using the style attribute
<h1 style="color: red; font-size: 12px;">Using inline styles</h1>CSS Foundations
Used to style a single HTML element using the style attribute
<h1 style="color: red; font-size: 12px;">Using inline styles</h1>CSS Foundations
Add the <style> element within the HTML <head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Foundations</title>
</head>
<body>
<h1>My Site Header</h1>
</body>
</html>
CSS Foundations
Add the <style> element within the HTML <head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Foundations</title>
<style>
h1 {
color: red;
font-size: 12px;
}
</style>
</head>
<body>
<h1>My Site Header</h1>
</body>
</html>
CSS Foundations
Also not recommended because it is hard to maintain and no separation of concerns.
When is it useful?
CSS Foundations
Link an external stylesheet (.css) to your HTML file
/* styles.css */
h1 {
color: red;
font-size: 12px;
}CSS Foundations
Link an external stylesheet (.css) to your HTML file
/* styles.css */
h1 {
color: red;
font-size: 12px;
}<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Foundations</title>
<!-- link the stylesheet here -->
</head>
<body>
<h1>My Site Header</h1>
</body>
</html>
CSS Foundations
Link an external stylesheet (.css) to your HTML file
/* styles.css */
h1 {
color: red;
font-size: 12px;
}<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Foundations</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<h1>My Site Header</h1>
</body>
</html>
CSS Syntax
CSS Syntax
| Property | Usage |
|---|---|
| color | sets the font color |
| font-family | sets the font type |
| font-size | sets the font size |
| font-weight | sets the thickness of the font |
| text-align | sets the alignment of the text |
| background-color | sets the background color of the element |
| border | sets the border style of the element |
| height | sets the height of the element |
| width | sets the width of the element |
CSS Syntax
For inline styling, it's simple
<h1 style="color: red; font-size: 12px;">Using inline styles</h1>CSS Syntax
For internal and external stylesheets, we use selectors
/* styles.css */
body {
color: red;
font-size: 24px;
}
CSS Syntax
For internal and external stylesheets, we use selectors
/* styles.css */
body {
color: red;
font-size: 24px;
}
h1 {
color: blue;
border: 1px solid green;
}
CSS Syntax
but problem....
CSS Syntax
You can define your own selectors using the class and/or id attributes on an element.
CSS Syntax
CSS Syntax
Check out the tutorials on HTML Dog
CSS Box Model
Margins, Paddings, and Borders
Building Container Elements