1. Descendant Selector
<!DOCTYPE html> <html> <head> <style> div > p { background-color: yellow; } </style> </head> <body> <div> <p>Paragraph 1 in the div.</p> <p>Paragraph 2 in the div.</p> <section><p>Paragraph 3 in the div.</p></section> <!-- not Child but Descendant --> <p>Paragraph 4 in the div.</p> </div> <p>Paragraph 5. Not in a div.</p> <p>Paragraph 6. Not in a div.</p> </body> </html> <!DOCTYPE html> <html> <head> <style> div > p { background-color: yellow; } </style> </head> <body> <div> <p>Paragraph 1 in the div.</p> <p>Paragraph 2 in the div.</p> <section><p>Paragraph 3 in the div.</p></section> <!-- not Child but Descendant --> <p>Paragraph 4 in the div.</p> </div> <p>Paragraph 5. Not in a div.</p> <p>Paragraph 6. Not in a div.</p> </body> </html>
<!DOCTYPE html> <html> <head> <style> div ~ p { background-color: yellow; } </style> </head> <body> <p>Paragraph 1.</p> <div> <p>Paragraph 2.</p> </div> <p>Paragraph 3.</p> <code>Some code.</code> <p>Paragraph 4.</p> </body> </html>