HTML/CSS/Layout/Position Selector
Содержание
Descendant Selector
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> div *.my-class {
font-size:1.2em; font-weight:bold;
} </style> </head> <body>
p.my-class
- div ol li
- div ol li
-
div ol li p.my-class
</body> </html>
</source>
Descendant Selector: id element
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css">
- my-id p {
background-color:gold;
}
</style> </head> <body>
p.my-class
- div ol li
- div ol li
-
div ol li p.my-class
</body> </html>
</source>
Position Selectors Demo
<source lang="html4strict">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> div * .my-class {
font-size: 1.2em; font-weight: bold;
} </style> </head> <body>
p.my-class
- div ol li
- div ol li
-
div ol li p.my-class
</body> </html>
</source>
To select descendant elements
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css">
- my-id p { background-color:gold; }
</style> </head> <body>
p.my-class
- div ol li
- div ol li
-
div ol li p.my-class
</body> </html>
</source>