Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

CSS Interview Questions and Answers

Test your skills through the online practice test: CSS Quiz Online Practice Test

Related differences

CSS 2 vs CSS 3

Ques 1. As a reader, how can I make my browser recognize my own style sheet?

Netscape
It is not possible to do this in Netscape yet (as of version 4.0.)
Internet Explorer 3.0 (Win95/NT)
[It is possible to do this at least in Windows95/NT, but no user interface is provided. Unknown how this might be accomplished on other operating systems.]

1. Open the Registry editor (Start..Run..regedit..ENTER)
2. Under the 'HKEY_LOCAL_MACHINE\Software\Microsoft\InternetExplorer\Styles' key, Edit..New..String Value
3. The new value should be called 'StyleSheet Pathname'
4. For the value, type in the full directory path of your .css style sheet.

Internet Explorer 4.0 (Win95/NT)

1. Under the View menu, select 'Internet Options'.
2. Under the 'General' tab, choose the 'Accessibility' button.
3. Choose the 'Format documents using my style sheet' check box and 'Browse...' to the location of your .css style sheet.

Is it helpful? Add Comment View Comments
 

Ques 2. How do I get rid of the gap under my image?

Images are inline elements, which means they are treated in the same way as text. Most people kind of know this - they know that if you use 'text-align:center' on an image it will be centred. What many people don't realise is that this means you will have a gap underneath an image. This gap is for the descenders of letters like j,q,p,y and g. To get rid of this gap you need to make the image block-level - like this :

CSS
img {display:block;}

One problem that this can cause is when you want to have a few images next to each other - if they are block-level, they won't be next to each other. To get around that, you can use float:left. Of course, this might present another problem - maybe you don't want the image to float left. In this case, you can use an unordered list like this :

CSS
ul, li {
list-style-type:none;
padding:0;
margin:0 auto;
}
ul {
width:150px;
}
li {
float:left;
}
HTML
<ul>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
<li><img src="wine.jpg" height="50" width="50" alt="wine" /></li>
</ul>

Is it helpful? Add Comment View Comments
 

Ques 3. Why use Style Sheets?

Style sheets allow a much greater degree of layout and display control than has ever been possible thus far in HTML. The amount of format coding necessary to control display characteristics can be greatly reduced through the use of external style sheets which can be used by a group of documents. Also, multiple style sheets can be integrated from different sources to form a cohesive tapestry of styles for a document. Style sheets are also backward compatible - They can be mixed with HTML styling elements and attributes so that older browsers can view content as intended.

Is it helpful? Add Comment View Comments
 

Ques 4. What does the "Cascading" in "Cascading Style Sheets" mean?

Style Sheets allow style information to be specified from many locations. Multiple (partial) external style sheets can be referenced to reduce redundancy, and both authors as well as readers can specify style preferences. In addition, three main methods can be employed by an author to add style information to HTML documents, and multiple approaches for style control are available in each of these methods. In the end, style can be specified for a single element using any, or all, of these methods. What style is to be used when there is a direct conflict between style specifications for an element?
Cascading comes to the rescue. A document can have styles specified using all of these methods, but all the information will be reduced to a single, cohesive "virtual" Style Sheet. Conflict resolution is based on each style rule having an assigned weight according to its importance in the scheme of things. A rule with a higher overall importance will carry a higher weight. This will be used in place of a competing style rule with a lower weight/importance. A hierarchy of competing styles is thus formed creating a "cascade" of styles according to their assigned weights. The algorithm used to determine this cascading weight scale is fairly complex.

Is it helpful? Add Comment View Comments
 

Ques 5. What is CSS rule 'at-rule'?

There are two types of CSS rules: ruleset and at-rule. At-rule is a rule that applies to the whole style sheet and not to a specific selector only (like in ruleset). They all begin with the @ symbol followed by a keyword made up of letters a-z, A-Z, digits 0-9, dashes and escaped characters, e.g. @import or @font-face.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook