Selectors in CSS3 - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: CSS3 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=5) +--- Thread: Selectors in CSS3 (/showthread.php?tid=5159) |
Selectors in CSS3 - Qomplainerz - 07-26-2023 Example: <!DOCTYPE html> <html> <head> <title>Selectors Example</title> <style> /* Select the paragraph elements and apply a red text color */ p { color: red; } /* Select all elements with the class "highlight" and apply a yellow background color */ .highlight { background-color: yellow; } </style> </head> <body> <p>This is a paragraph with red text color.</p> <p class="highlight">This is a highlighted paragraph with a yellow background.</p> </body> </html> Explanation: CSS selectors are used to target specific HTML elements for styling. In this example, we use two types of selectors: the element selector (p) targets all p elements and applies a red text color to them. The class selector (.highlight) targets all elements with the class "highlight" and applies a yellow background color. |