Professional Documents
Culture Documents
1-3 CSS Intro 1 - 1 What Is CSS
1-3 CSS Intro 1 - 1 What Is CSS
15 <div class="highlight">
16 Div with <b>highlight</b> class
17 </div>
18 </body>
19 </html>
index.html
There are many ways to add CSS 1 <!DOCTYPE>
to your HTML, but we need to 2
3
<html>
<head>
start by creating an HTML file. 4
5
<title>Intro to CSS</title>
</head>
6 <body>
7 <div class="highlight">
8 Div with <b>highlight</b> class
Let's create 3 DIVs, the first and 9
10
</div>
15 <div class="highlight">
16 Div with <b>highlight</b> class
17 </div>
18 </body>
19 </html>
index.html
There are many ways to add CSS 1 <!DOCTYPE>
to your HTML, but we need to 2
3
<html>
<head>
start by creating an HTML file. 4
5
<title>Intro to CSS</title>
</head>
6 <body>
7 <div class="highlight">
8 Div with <b>highlight</b> class
Let's create 3 DIVs, the first and 9
10
</div>
15 <div class="highlight">
16 Div with <b>highlight</b> class
17 </div>
18 </body>
19 </html>
index.html
There are many ways to add CSS 1 <!DOCTYPE>
to your HTML, but we need to 2
3
<html>
<head>
start by creating an HTML file. 4
5
<title>Intro to CSS</title>
</head>
6 <body>
7 <div class="highlight">
8 Div with <b>highlight</b> class
Let's create 3 DIVs, the first and 9
10
</div>
15 <div class="highlight">
16 Div with <b>highlight</b> class
17 </div>
18 </body>
19 </html>
Adding CSS to the HTML
There are three different ways you can use CSS to style your HTML:
Inline styles
Internal Stylesheet
External Stylesheets
Let’s see the difference!
1 | Inline Styles
If you're looking to add a unique style for a The example shows us changing the
single HTML element, you can use an inline HTML body's background to red:
style.
index.html
It can also be used to test different styles,
initially, or for quick fixes, as it's much easier 1 <!DOCTYPE>
2 <html>
to change a single element on the page than 3 <head>
4 <title>Intro to CSS</title>
to find and change the source CSS file. 5
6
</head>
<body style="background: red">
7 <div class="highlight">
8 Div with <b>highlight</b> class
10 </body>
11 </html>
2 | Internal Stylesheet
1 <!DOCTYPE>
2. Link the style.css file in the HTML 2
3
<html>
<head>
4
5
<title>Intro to CSS</title>
<link rel="stylesheet" href="css/style.css">
6 </head>
7 <body>
8 </body>
9 </html>
Let’s add more stuff
https://codepen.io/f3r/embed/f8160ebc20f8794c34afb547fcea6434
PRO TIP // You can combine properties
css/style.css css/style.css
1 div { 1 div {
2 font: 15px Arial, sans-serif; 2 border: 1px solid black;
3 /* 3 /*
4 font-size: 15px; 4 border-width: 1px;
5 font-family: Arial, sans-serif; 5 border-style: solid;
6 */ 6 border-color: black;
7 } 7 */
8 }