Skip to content

Commit 100b79d

Browse files
author
James Halliday
committed
css selector rules
1 parent 22171ed commit 100b79d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

html.markdown

+37
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,47 @@ use a class when there could be many elements
227227

228228
view the source on http://cyber.wizard.institute & explore
229229
the stylesheet.
230+
---
231+
# css selectors
232+
233+
You can create blocks of css rules that apply to more than
234+
just individual classes and ids with css selectors.
235+
236+
``` css
237+
#page .row .title {
238+
color: cyan;
239+
}
240+
```
230241

242+
will match `<div class="title"></div>` in:
243+
244+
``` html
245+
<div id="page">
246+
<div class="row">
247+
<div class="header">
248+
<div class="title"></div>
249+
<div class="date"></div>
250+
<div class="author"></div>
251+
</div>
252+
</div>
253+
</div>
254+
```
231255
---
256+
# css selectors
232257

258+
We just used spaces between elements in `#page .row .title`,
259+
but we can do lots of other things with css:
233260

261+
* `E` - match an element E by its tag name (example: `h1`)
262+
* `E F` - matches F, a descendant of E
263+
* `E > F` - matches F, a direct child of E
264+
* `E#abc` - matches an element E with an id of abc
265+
* `E.xyz` - matches an element E with a class of xyz
266+
* `E[foo="bar"]` - match an element E with an attribute
267+
`foo` equal to "bar"
268+
269+
and more! http://www.w3.org/TR/CSS2/selector.html#pattern-matching
270+
---
234271
# neocities
235272

236273
You can host your html on neocities for free!

0 commit comments

Comments
 (0)