element1~element2
In this chapter you will learn:
- Definition for Selector element1~element2
- An example showing how to use element1~element2 CSS selector
Description
The element1~element2
selector selects element2
that are preceded by element1
.
Both elements must have the same parent.
element2
does not have to be immediately preceded by element1
.
Example
<!DOCTYPE html><!-- ja va 2 s .c om-->
<html>
<head>
<style>
p~h2{
background:red;
}
</style>
</head>
<body>
<div>A div element.</div>
<p>The first paragraph.</p>
<h2>Another list</h2>
<p>The second paragraph.</p>
</body>
</html>
Next chapter...
What you will learn in the next chapter:
Home » HTML CSS Tutorial » CSS Selector Reference