|
1 | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | 2 | <html lang="en"> |
3 | | -<!-- $Id: cascade.src,v 2.5 1998-02-21 00:04:43 ijacobs Exp $ --> |
| 3 | +<!-- $Id: cascade.src,v 2.6 1998-02-21 02:36:41 bbos Exp $ --> |
4 | 4 | <HEAD> |
5 | 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
6 | 6 | <TITLE>Assigning property values, Cascading, and Inheritance</TITLE> |
@@ -291,8 +291,9 @@ must apply the following algorithm:</p> |
291 | 291 |
|
292 | 292 | <LI> |
293 | 293 | Sort by specificity of selector: more specific selectors will |
294 | | - override more general ones. The definition and calculation of |
295 | | - specificity is object-language dependent. Pseudo-elements and |
| 294 | + override more general ones. <!-- The definition and calculation of |
| 295 | + specificity is object-language dependent. [I don't think so. BB]--> |
| 296 | + (see <a href="#specificity">below</a>) Pseudo-elements and |
296 | 297 | pseudo-classes are counted as normal elements and classes, |
297 | 298 | respectively. |
298 | 299 |
|
@@ -356,16 +357,20 @@ since the author's "!important" rule takes precedence.</p> |
356 | 357 | </div> |
357 | 358 |
|
358 | 359 |
|
359 | | -<H3>Cascading order in HTML</H3> |
360 | | -<P>In HTML, a selector's specificity is calculated as follows:</p> |
| 360 | +<H3><a name="specificity">Calculating a selector's specificity</a></H3> |
| 361 | +<P>A selector's specificity is calculated as follows:</p> |
361 | 362 |
|
362 | 363 | <ul> |
363 | 364 | <li>(a) count the number of "id" attributes in the selector |
364 | 365 | <li>(b) count the number of other attributes in the selector |
365 | | -(including class attributes) |
366 | 366 | <li>(c) count the number of element names in the selector |
367 | 367 | </ul> |
368 | 368 |
|
| 369 | +<p>Classes (only in selectors for HTML) and <a |
| 370 | +href="selector#pseudo-classes">pseudo-classes</a> are counted as |
| 371 | +attributes. <a href="selector#pseudo-elements">Pseudo-elements</a> are |
| 372 | +not counted. |
| 373 | + |
369 | 374 | <P>Concatenating the three numbers (in a number system with a large |
370 | 375 | base) gives the specificity. |
371 | 376 |
|
|
0 commit comments