CSS Interview Questions and Answers
Ques 21. What is a Style Sheet?
Ans. Style sheets are the way that standards-compliant Web designers define the layout, look-and-feel, and design of their pages. They are called Cascading Style Sheets or CSS. With style sheets, a designer can define many aspects of a Web page:
Style sheets give you a lot of power to define how your pages will look. And another great thing about them is that style sheets make it really easy to update your pages when you want to make a new design. Simply load in a new style sheet onto your pages and you\'re done.
Ques 22. What is alternate Style Sheet? How to link?Ans. Alternate Style Sheet is a sheet defining an alternate style to be used in place of style(s) declared as persistent and/or preferred .
Persistent style is a default style that applies when style sheets are enabled but can disabled in favor of an alternate style, e.g.:
<LINK REL=Stylesheet HREF=\"style.css\" TYPE=\"text/css\">
Preferred style is a default style that applies automatically and is declared by setting the TITLE attribute to the LINK element. There can only be one preferred style, e.g.:
<LINK REL=Stylesheet HREF=\"style2.css\" TYPE=\"text/css\" TITLE=\"appropriate style description\">
Alternate style gives an user the choice of selecting an alternative style - a very convenient way of specifying a media dependent style. Note: Each group of alternate styles must have unique TITLE, e.g.:
<LINK REL=\"Alternate Stylesheet\" HREF=\"style3.css\" TYPE=\"text/css\" TITLE=\"appropriate style description\" MEDIA=screen>
<LINK REL=\"Alternate Stylesheet\" HREF=\"style4.css\" TYPE=\"text/css\" TITLE=\"appropriate style description\" MEDIA=print>
Alternate stylesheet are not yet supported.
<!--[if gte IE 5]> <style type=\"text/css\">
width:expression(documentElement.clientWidth < 780 ? (documentElement.clientWidth == 0 ? (body.clientWidth < 780 ? \"780px\" : \"auto\") : \"780px\") : \"auto\" );
As the property is non-standard, it won\'t validate with the W3C validator, so if we put it in the head like this (above) - in an IE conditional comment - the validator will ignore it and the page will get a clean bill of health.
Ques 24. Which browsers support CSS?Ans. It depends on your definition of \"support.\" If you are interested in those browsers which makes some attempt at supporting CSS, no matter how partial or bug-ridden, then the list is:
* Internet Explorer 3.0 and above
* Navigator 4.0 and above
* Opera 3.6 and above
* XPublish by Media Design inĚProgress
If instead you\'re interested in those browsers which are known to do a credible job of bug-free and mostly completel support for CSS1, then the list narrows somewhat dramatically:
* Internet Explorer 5.0 for Macintosh and above
* Internet Exporer 5.5 for Windows and above
* Netscape Navigator 6.0 and above
* Opera 4.0 and above
While none of these browser can be claimed to have a perfect implementation of CSS1, they are all quite good and can be relied upon to operate in a consistent fashion for most of CSS1.
Ques 25. How do I place text over an image?Ans. To place text or image over an image you use the position property. The below exemple is supported by IE 4.0. All you have to do is adapt the units to your need.
<div style=\"position: relative; width: 200px; height: 100px\">
<div style=\"position: absolute; top: 0; left: 0; width: 200px\">
<div style=\"position: absolute; top: 20%; left: 20%; width: 200px\">
Text that nicely wraps
Most helpful rated by users: