• +91 9723535972
  • info@interviewmaterial.com

CSS Interview Questions and Answers

Related Subjects

CSS Interview Questions and Answers

Question - 71 : - Which characters can CSS-names contain?

Answer - 71 : - The CSS-names; names of selectors, classes and IDs can contain characters a-z, A-Z, digits 0-9, period, hyphen, escaped characters, Unicode characters 161-255, as well as any Unicode character as a numeric code. The names cannot start with a dash or a digit. (Note: in HTML the value of the CLASS attribute can contain more characters).

Question - 72 : - What browsers support style sheets? To what extent?

Answer - 72 : - Microsoft's Internet Explorer version 3.0 Beta 2 and above supports CSS, as does Netscape Communicator 4.0 Beta 2 and above and Opera 3.5 and above. Take note that the early implementations in these browsers did not support ALL of the properties and syntax described in the full CSS1 specification and beyond. Later versions have been getting much closer to full CSS1 compliance, but then comes the next hurdle - CSS2...it was such a big leap over CSS1 that it has taken the browsers years to come close to supporting a majority of CSS2's features. Mozilla and Opera's current versions both offer excellent CSS standards compliance. The Macintosh version of Internet Explorer is said to be very impressive in its CSS capabilities as well, but PC IE lags behind these implementations. Quite a few other implementations of CSS now exist in browsers that are not as widely-used (such as Amaya, Arena and Emacs-W3), but coverage of features in these documents currently only covers Internet Explorer, NCSA Mosaic, Netscape and Opera browsers.

Question - 73 : - What is cascading order?

Answer - 73 : - Cascading order is a sorting system consisting of rules by which declarations are sorted out so that there are not conflicts as to which declaration is to influence the presentation. The sorting begins with rule no 1. If a match is found the search is over. If there is no match under rule no 1 the search continues under rule no 2 and so on. 1. Find all declarations that apply to a specific selector/property and Declare the specified style if the selector matches the element if there isn't any Let the element inherit its parent property if there isn't any Use initial value 2. Sort by weight (! important) Increased weight take precedence over normal weight 3. Sort by origin Rules with normal weight declared in author's style sheet will override rules with normal weight declared in user's personal style sheets Rules with increased weight declared in user's personal style sheet will override rules with normal weight declared in author's style sheet Rules with increased weight declared in author's style sheet will override rules with increased weight declared in user's personal style sheets Author's and user's rules will override UA's default style sheet. 4. Sort by selector's specificity More specific selector will override less specific one: ID-selector (most specific), followed by Classified contextual selectors (TABLE P EM.fot) Class selectors (EM.fot) Contextual selectors - the "lower down" the more weight, (TABLE P EM), (TABLE P EM STRONG) - STRONG has more weight than EM. 5. Sort by order specified If two rules have the same weight, the latter specified overrides ones specified earlier. Style sheets are sorted out as follows: The STYLE attribute (inline style) overrides all other styles The Style element (embedded style) overrides linked and imported sheets The LINK element (external style) overrides imported style The @import statement - imported style sheets also cascade with each other in the same order as they are imported

Question - 74 : - Why shouldn't I use fixed sized fonts ?

Answer - 74 : - Only in very rare situations we will find users that have a "calibrated" rendering device that shows fixed font sizes correct. This tells us that we can never know the real size of a font when it's rendered on the user end. Other people may find your choice of font size uncomfortable. A surprisingly large number of people have vision problems and require larger text than the average. Other people have good eyesight and prefer the advantage of more text on the screen that a smaller font size allows. What is comfortable to you on your system may be uncomfortable to someone else. Browsers have a default size for fonts. If a user finds this inappropriate, they can change it to something they prefer. You can never assume that your choice is better for them. So, leave the font size alone for the majority of your text. If you wish to change it in specific places (say smaller text for a copyright notice at the bottom of page), use relative units so that the size will stay in relationship to what the user may have selected already. Remember, if people find your text uncomfortable, they will not bother struggling with your web site. Very few (if any) web sites are important enough to the average user to justify fighting with the author's idea of what is best.

Question - 75 : - How do you make a whole div into a link?

Answer - 75 : - You can't put 'a' tags around a div, but you can do this with javascript : HTML

... stuff goes here ...
If you want to use an empty div with a background image as a link instead of putting your image into the html, you can do something like this: CSS #empty { background-image:url(wine.jpg); width:50px; height:50px; margin:auto; } #empty a { display:block; height:50px; } * html #empty a { display:inline-block; } HTML

Question - 76 : - How do I have links of different colors on the same page?

Answer - 76 : - Recommending people to use classes in their 'a' tags like this : CSS a.red { color:red; } a.blue { color:blue; } HTML A red link A blue link This is a valid way to do it, but usually, this isn't what a page looks like - two links next to each other with different colours - it's usually something like a menu with one kind of link and main body text or another menu with different links. In this (normal) situation, To go higher up the cascade to style the links. Something like this : CSS a { color:red; } #menu a { color:blue; } HTML

There's a blue link here.

Question - 77 : - What is shorthand property?

Answer - 77 : - Shorthand property is a property made up of individual properties that have a common "addressee". For example properties: font-weight, font-style, font-variant, font-size, font-family, refer to the font. To reduce the size of style sheets and also save some keystrokes as well as bandwidth they can all be specified as one shorthand property font, e.g.: H1 {font-weight: bold; font-style: italic; font-variant: small-caps; font-size: 160%; font-family: serif} can be all shorthanded to a space separated list: H1 {font: bold italic small-caps 160% serif} Note: To make things even simpler the line-height property can be specified together with the font-size property: H1 {font: bold italic small-caps 160%/170% serif} How to use CSS building a standards based HTML template? It should: 1. Contain: header, navigation, content, footer 2. Use well-structured HTML 3. Be error-free and encourage good coding Let’s start with number one there: HTML document split up in four parts all with different meaning, use the -tag. Div is short for “division” and isn’t header, navigation and so on ... !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> Your own page title

Hello World

Content of the element P will also have red background

Question - 80 : - How frustrating is it to write a specification knowing that you're at the browser vendors' mercy?

Answer - 80 : - That's part of the game. I don't think any specification has a birthright to be fully supported by all browsers. There should be healthy competition between different specifications. I believe simple, author-friendly specifications will prevail in this environment. Microformats are another way of developing new formats. Instead of having to convince browser vendors to support your favorite specification, microformats add semantics to HTML through the CLASS attribute. And style it with CSS.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners