Simple Sel
What is the purpose of using an ID selector in CSS?
Notes
Simple Selectors Like calling someone by name; use Tag name, ID, or Class selectors to point toward your HTML elements. Using id Using an element selectors, meaning we used the <tag> or element name Next, focus on the element with the id para1 The id is unique and only used to identify a single element in the page Using class Now we are going to group the class attribute text, center. The class selector allows us to apply a style to different elements. Grouping styles Grouping styles in CSS lets you apply the same styles to multiple elements. Instead of writing separate rules for each element you can group them by separating each selector by a comma , To apply the same background color to h1, h2, and the p element you would write h1,h2,p {background-color: cornsilk;} this ensures consistency when sharing the same properties. <html> <head> <style> p { color: SlateBlue; } #para1 { font-weight: bold; font-size: 130%;} .center { text-align: center;} h1, h2, p {background-color: cornsilk;} </style> </head> <body> <h1 class="center">CSS Selector Example</h1> <h2 class="center">Different way to select elements</h1> <p>Example Paragraph one.</p> <p id="para1" class="center"> Examp...
Study with interactive games
Upload your notes and generate flashcards, exams and more with AI
Start for free