CSS is mainly developed to separate content in the HTML document to presentation document. Different styles of web pages can be placed in CSS file which helps in modifying the presentation content easily. It is necessary to have knowledge on CSS, to develop web page. The interview questions presented in this article are frequently asked in most of the interviews by the employers. These are the technical questions asked to the candidates who are attending interview related to web designing. A list of CSS interview questions and answers are given below:
1. Define cascading style sheets?
A designer makes use of cascading style sheets in different ways. Mainly, it helps in designing style sheets for HTML and content pages. It is applicable to any markup language or XML document.
2. Describe features of CSS?
CSS use some features to define fonts, colors, layout, etc. The content is separated from the design part which makes content visible thereby enhancing productivity of the complete process. Same page is made to appear in various formats.
3. Describe the rules in style sheets?
In style sheets, a big list of rules is defined. Every rule contains declaration block and selectors. Declaration block contains declarations which are defined and separated using semicolon in curly braces. Additionally, every declaration has a property, colon and a semicolon.
4. Describe hover element?
A hover element is activated if the user moves pointer on the area in which HTML code is defined. Mainly, this style is used for online advertising. It can be appended to #elementid:hover.
5. Give some uses of CSS?
Various possibilities are offered to developer and designer by CSS. Some of them are given below:
• Complete style sheet coding is moved to isolated external folder.
• CSS is made rich because it contains code reuse and repetition.
• Structure and presentation are made different by CSS etc.
6. Explain different types of author styles?
A developer, web page author, designer, etc describe styles in various forms they are:
• Embedded style
• External style sheets and
• Local and default style sheet
• Inline styles
7. What is the main aim of applying style sheets?
The main use of style sheet is to ensure great degree of control on his presentation to the user. If the user does not like some font then he can modify it without any difficulty. The effects of browser on the application or text part of a web page are minimized by the developer. Control on the complete web page without external influences, isolation of page from code part of HTML.
8. Describe CSS1?
The adoption of W3C is recommended in the year 1996. Some of the features and capabilities of CSS1 are given below:
• Text colors, background colors, etc
• Font properties
• Images, table’s alignment
• Spacing between words, text, etc
• Margin, border, positioning and padding of elements
• Attributes are identified uniquely and generally classified.
The specifications present in CSS1 are adopted by W3C.
9. Give the extra features in CSS2 compared to CSS1?
There are many features in CSS2 and some of them are given below:
• Elements positioning will be according to fixed, relative and absolute positioning.
• Large number of media functions is added.
• Bidirectional, shadows support for aural and text style sheet.
10. Describe CSS filter?
The difficulties faced by designers and developers are solved using CSS filter. These filters are used to write completely different code or change the current design patterns so that the CSS specifications are received by the browsers. Thus, browsers are not allowed to make any changes which are not required.
11. Describe internet explorer box model bug?
Designers had tough time while dealing with this bug because box widths are not displayed perfectly on the web page. The block is displayed to be in narrow size. Hacks and CSS filter are used to rectify this bug. This problem can also be solved with correct usage and documentation of XHTML.
12. Describe vertical control limitation?
Vertical control limitations are always considered as a nightmare for the designers. Horizontal positioning of element or text is easy but vertical positioning the element leads to impossible and complex tasks. For vertical placements of elements, CSS has unsupported rules.
13. Describe absence of expressions?
Currently, CSS does not have ability to state property values as simple expressions. Example: if you are interested in calculating size of all columns but there is restriction on sum of all columns. This issue is solved by most of the browsers by proprietary expressions which do a good job.
14. Describe lack of orthogonality?
Various jobs are explained by lack of orthogonality which is used many times for same job or undefined correctly for particular application. CSS defines that there are no margins in the internal elements of a table so it is better to use border spacing which may lead to confusion.
15. Describe ease of maintenance with CSS?
A good style sheet has effective use of cascading style sheets and inheritance. If there is any change to a single element of global style sheet then all the elements on the web page are changed. Thus, maintenance is made easy as the style of entire page is changed by making modifications to single element.
16. Describe float containment?
Float elements are not supported by CSS because it results in overflow. Float also varies according to the size and resolution of web browser whereas positions do not. There are various properties which are defined about float but they have own restrictions.
17. Give the limitations of style sheets?
Style sheets have own limitations and some of them are given below:
• Vertical control limitations
• Inconsistent browser support
• Some of the limitations present in CSS are lack of column declaration and variables.
• Float containment, margin collapsing, control of element shapes, etc