Selectors in CSS
Selectors are used to target specific HTML elements and apply styles to them. There are several types of selectors, including:
Element selectors: Target all instances of a particular HTML element. For example, to target all paragraphs on a page, you can use the p selector:
css
Copy code
p {
font-size: 16px;
color: #333;
}
Class selectors: Target elements with a specific class attribute. For example, to target all elements with the class highlight, you can use the .highlight selector:
css
.highlight {
background-color: yellow;
}
ID selectors: Target a specific element with a unique ID attribute. For example, to target the element with the ID header, you can use the #header selector:
css
#header {
font-size: 24px;
color: blue;
}
No comments:
Post a Comment