Skip to content

Commit 4cf85a1

Browse files
committed
module3.2.2
1 parent 5fae36c commit 4cf85a1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

module3.2.2_classes_ids/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Classes and IDs</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
<h1>Classes and IDs</h1>
10+
<p id="intro">
11+
Classes and IDs are "attribute selectors". This means that you can attach style to HTML elements based on that element's attributes. This empowers you to apply different style to items of the same HTML type.
12+
</p>
13+
<p class="odd">
14+
Classes are an HTML attribute that specifies a name for a group of elements on the page. You can apply the class name to as many elements as you like, even if they are of different HTML tag types. You can use the class name with a period in front as the selector.
15+
</p>
16+
<p class="even">
17+
Class names must be single words, but you can include digits and dashes as long as the name begins with a letter. Note that names are case sensitive.
18+
</p>
19+
<p class="odd">
20+
An ID is an HTML attribute that specifies a name or unique identifier for a particular HTML element. They are like classes with a very important distinction: the value of the ID attribute must be unique throughout the document. This lets you target a single HTML element for styling.
21+
</p>
22+
<p class="even">
23+
ID names have the same rules as class names: start with a letter, can include numbers and dashes, no spaces. The way to create a selector for an ID is also similar to how you create a selector for a class, except you replace the period with a hash symbol ("#").
24+
</p>
25+
</body>
26+
</html>

module3.2.2_classes_ids/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#intro {
2+
color: green;
3+
}
4+
.odd {
5+
color: blue;
6+
}
7+
.even {
8+
color: red;
9+
}

0 commit comments

Comments
 (0)