CSS selector are used to select those content which we want to style. CSS selector is used to select HTML elements according to its id, class, type, attribute etc.
Types of CSS selector:-
- CSS element selector
- CSS Id selector
- CSS Class selector
- CSS universal selector
- CSS Group selector
- Css Element selector:- CSS element selector selects the HTML element by name.
- CSS Id Selector:- The Id selector selects the id attributes of an HTML element to select a specific element. An id is always unique within the page so it is chosen to select a single, unique element.
- CSS Class Selector:- It select the HTML elements with a specific class attribute. It is used with a period character .(full stop symbol) followed by the class name.
- CSS Universal Selector:- The universal selector is used as a wildcard character. It selects all elements on the page.
- CSS Group Selector:- It is used on those elements which have same style definations. Grouping selector is used to minimize the code. Commas are used to separate each selector in grouping.
CSS Comments:- CSS comments are generally written to explain your code. It is very helpful fir the users who reads your code so that they can easily understand the code. Comments are ignored by the browsers. Comments are the single line or multiple line statements and written in /*……..*/ .
CSS Background:- This property is used to define the backgroud effects on elements. There are 5 CSS background properties that affect the HTML elements.
- CSS Background-color:- This property is used to specify the background color of element.
You can set the background color like this:
2.CSS background-image:- The background-image property is used to set an image as a background of an element. By default the image covers the entire element. Example:-
3. CSS background-repeat:- BY default,
the background-image property repeats the background image horizontally and vertically. Some images are repeated only horizontally or vertically.
The background looks better if the image repeated horizontally only.
4. CSS background-attachment:- Thisproperty is used to specify if the background image is fixed or scroll with the rest of the page in browser window. If you set fixed the background image then the image will not move during scrolling in the browser. example:-
5.CSS background-position:- The background-position property is used to define the initial position of the background image. By default, the background image is placed on the top-left of the webpage. we can set the following positions:-