css selectors
7/05/2021
Hacker
CSS Selector
CSS selectors are one of the most important parts of CSS. They provides the ability to target the HTML elements on the web page that we want to style.
The CSS selector is the first part of a CSS rule. It is a pattern of elements and other words that tells the browser which HTML elements should be selected to have CSS property values within the rule that applies to them. The element or elements selected by the selector are called the subject of the selector.
The selector indicates the HTML element you want to style.
A CSS selector is a pattern for matching elements on a web page. The CSS style rules associate with those CSS selector will be apply to elements that matches selector pattern.
CSS selectors are one of the most important part of CSS because they allows to target specific elements on web page in a various ways to style them.
- CSS selectors define elements to which a set of CSS rules are applied.
- The selector is an HTML element that you want to style.
- Web Scraper uses CSS selectors to discover HTML elements in the web pages and extracts the data from them.
- These tell the browser which elements to apply CSS property values to.
Syntax
- selector { property: value; }
Types of CSS Selector
There are many different types of CSS selectors, each with its own specific syntax.
- Simple selectors
- Combinator selectors
- Pseudo-class selectors
- Pseudo-elements selectors
- Attribute selectors
Simple Selector
It selects elements based on name, id, class
Simple CSS selectors directly select one or more elements based on the type, class, or id of the element.
Simple selectors are the most usualy used CSS selectors which helps in styling HTML tags such as section, div, h1, article , etc. tags and its elements that have ID's and classes.
Types of CSS Simple Selector
There are five types of CSS simple selector
- CSS Element Selector
- CSS Id Selector
- CSS Class Selector
- CSS Universal Selector
- CSS Group Selector
Combinator selectors
Combinator is something that explains the relationship between selectors.
A CSS selector can have more than one simple selector. Among the simple selectors, we can include a combinator.
CSS selectors are patterns used to select elements for style purposes.
Types of css combinators
There are four different combinators in CSS
- descendant selector (space)
- child selector (>)
- adjacent sibling selector (+)
- general sibling selector (~)
Pseudo-classes selector
A pseudo-class is used to define a special state of an element.
CSS pseudo-classes are used to add special effects to some selectors. You don't need to use JavaScript or any other script to use those effects.
Pseudo-Elements
A CSS pseudo-element is used to style specified parts of an element.
CSS pseudo-elements are used to add special effects to some selectors.
Attribute selector
The attribute selector is used to select elements with the specified attribute.
It is a famous way to style HTML elements through grouping them depending on certain attributes and this will select those elements with same attributes.
Types of attribute selector
There are two types of css attribute selector.
- Presence and value selectors
- Substring matching selectors
No comments:
Post a Comment