Previous Next

Interview Questions on CSS

1. What is CSS ?

CSS Stands for cascading style sheet.
Which is used to apply styles for html elements.
To decorate the webpage we use css styles.

2. How would you add css styles in HTML?

1. Inline styles :- use style attribute in html tag directly.
2. Embedded styles :- place <style> </style> in <head> tag and write styles in b/w <style></style>
3. External Style sheet :- link to external style sheet(.css) by using following syntax
Syn :-
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>

4. What are the Advantage and disadvantage of external style sheets?

Answer Not Given

5. What is the advantage of using embed styles instead of inline styles?

Inline styles : we have to re write same code for multiple html elements which has same type or class.
Embed styles :- you can write one style and apply it to same type or class at once. So no need to re write the code for all classes.

6. If you write same property in embed style sheet and inline style sheet. Which one the browser takes?

Inline style.

7. What to do if we don’t want to override property of embed styles in inline styles?

Use !important for the particular property.
Ex:- width:500px !important;

8. How to apply styles for HTML elements?

1. By using class name.
Ex:-
.classname{

}
2. By using id name
Ex:-
#id{
}
3. By using tag name
Ex:- div{
}

9. How to apply styles using class name?

By using dot . followed by classname
Syntax :-
.classsname{
Attribute : Value;
}
Ex:-
.container{
Font-size:14px;
Background-color:#F33;
}

10. How to apply styles using id name?

By using # followed by classname
Syntax :-
#idname{
Attribute : Value;
}
Ex:-
#container{
Font-size:14px;
Background-color:#F33;
}


Previous Next