css1.What is CSS?
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to simplify the process of making web pages presentable.

2.What are the components of a CSS Style?
A style rule is made of three parts −

Selector − A selector is an HTML tag at which a style will be applied. This could be any tag like <h1> or <table> etc.

Property − A property is a type of attribute of HTML tag. Put simply, all the HTML attributes are converted into CSS properties. They could be color, border etc.

Value − Values are assigned to properties. For example, color property can have value either red or #F1F1F1 etc.

3.What is type selector?
Type selector quite simply matches the name of an element type. To give a color to all level 1 headings −

h1 {
color: #36CFFF;
}

4.What is universal selector?
Rather than selecting elements of a specific type, the universal selector quite simply matches the name of any element type −

* {
color: #000000;
}
This rule renders the content of every element in our document in black.

5.What is Descendant Selector?
What is class selector?
You can define style rules based on the class attribute of the elements. All the elements having that class will be formatted according to the defined rule.

.black {
color: #000000;
}
This rule renders the content in black for every element with class attribute set to black in our document.

6.Can you make a class selector particular to an element type?
You can make it a bit more particular. For example −

h1.black {
color: #000000;
}
This rule renders the content in black for only <h1> elements with class attribute set to black.

7.What is id selector?
You can define style rules based on the id attribute of the elements. All the elements having that id will be formatted according to the defined rule.

#black {
color: #000000;
}
This rule renders the content in black for every element with id attribute set to black in our document.

8.Can you make a id selector particular to an element type?
ou can make it a bit more particular. For example −

h1#black {
color: #000000;
}
This rule renders the content in black for only <h1> elements with id attribute set to black.

9.What is a child selector?
Consider the following example −

body > p {
color: #000000;
}
This rule will render all the paragraphs in black if they are direct child of <body> element. Other paragraphs put inside other elements like <div> or <td> would not have any effect of this rule.

10.What is an attribute selector?
You can also apply styles to HTML elements with particular attributes. The style rule below will match all the input elements having a type attribute with a value of text −

input[type = “text”]{
color: #000000;
}
The advantage to this method is that the <input type = “submit” /> element is unaffected, and the color applied only to the desired text fields.

You may also like

Leave a Comment