CSS tutorial part-2

CSS Selector:-

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:-

  1. CSS element selector
  2. CSS Id selector
  3. CSS Class selector
  4. CSS universal selector
  5. CSS Group selector
  1. Css Element selector:- CSS element selector selects the HTML element by name.
  2. 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.
  3. 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.
  4. CSS Universal Selector:- The universal selector is used as a wildcard character. It selects all elements on the page.
  5. 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.

  1. background-color
  2. background-image
  3. background-repeat
  4. background-attachment
  1. 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:-

  1. centre
  2. top
  3. bottom
  4. left
  5. right
shashank K
Latest posts by shashank K (see all)
Tagged : / /
0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x