Skip to content

Commit 22171ed

Browse files
author
James Halliday
committed
css id, classes
1 parent fc2e907 commit 22171ed

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

html.markdown

+39-3
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ http://www.w3schools.com/html/html_css.asp)
152152

153153
---
154154

155-
# styles per class
155+
# styles per element
156156

157157
``` html
158158
<html>
@@ -179,12 +179,48 @@ h1 {
179179

180180
---
181181

182-
# styles for id's
183-
182+
# styles for ids
184183

184+
use an id when there will only be a single element
185185

186+
``` css
187+
<html>
188+
<head>
189+
<style>
190+
#msg {
191+
font-weight: bold;
192+
font-size: 72px;
193+
color: magenta;
194+
}
195+
</style>
196+
</head>
197+
<body>
198+
<div id="msg">wow!</div>
199+
</body>
200+
</html>
201+
```
202+
---
203+
# styles for class
186204

205+
use a class when there could be many elements
187206

207+
``` css
208+
<html><head>
209+
<style>
210+
.msg {
211+
font-weight: bold;
212+
font-size: 72px;
213+
color: magenta;
214+
}
215+
</style>
216+
</head>
217+
<body>
218+
<div class="cool">wow!</div>
219+
<div class="cool">neat!</div>
220+
<div class="cool">super!</div>
221+
</body></html>
222+
```
223+
---
188224
# external style sheets
189225

190226
`<link rel="stylesheet" href="style.css">`

0 commit comments

Comments
 (0)