Learn CSS Selectors
what Are CSS Selectors.
- CSS is Cascading Style Sheets selector determines which HTML elements your style apply.
- CSS rule consists of selector and block of declaration inside{...} define properties.
CSS Selectors
- css selectors patterns use css identify and select HTML element on webpage that styles can be applied to them.
- CSS selector type refers to different way can select HTML element.
- CSS selector has specific target elements.
Learn CSS Selectors
Type of CSS Selector (element)
1) Universal selector (*)
(code CSS )
* {
margin: 2px;
padding: 1px;
}
- * Selector all html element.
- * selector use to reset default browser spacing.
- * seletor applies styles to the entire page.
css code
- Element Selector all (paragraph) <p> Elements.
- change text color of every paragraph to blue.
3) Class Selector(.)
css code
.box {
background-color: yellow;
}
- . use before class name
- style all elements with class box
- classes can be used multiple
4) ID Selector(#)
css code
#title
{
font-size:30px;
}
- # used before ID name
- ID unique
code css
- Applies same style to multiple elements
- Save time and avoids repeated css
code css
input[type="email"]
{
border:2px solid green ;
}
code css
- :hover activates mouse over the link
- use for interaction effects
- example: :focus, :active, :visited
Learn CSS Selectors
Syntax
css
selector
{
property: value;
property: value;
}
Learn CSS Selectors
Explain Program