• +91 9723535972
  • info@interviewmaterial.com

CSS Interview Questions and Answers

Related Subjects

CSS Interview Questions and Answers

Question - 101 : - How do I move the list bullet to the left/right?

Answer - 101 : - CSS1 has no properties for setting margins or padding around the bullet of a list item and in most cases the position of the bullet is browser-dependent. This is especially true since most browsers disagreed on whether a bullet is found within the margin or padding of a list item. In CSS2, properties were introduced to provide greater control over the placement of bullets (which CSS2 calls a "marker") but these were not widely supported by mid-2001 browsers. Here is an example of changing a marker's placement: li:before {display: marker; marker-offset: 22px; content: url(triangle.jpg);} In this example, a graphic of a triangle is inserted before the content of the li element, set to be a marker (through display: marker;), and given an offset of 22 pixels. Depending on the margin size of the list item, there may not be room for the marker to appear next to the list item's content.

Question - 102 : - How does a simple CSS style rule look ?

Answer - 102 : - P { font-family: serif; font-size: 1.2em; } Here we see a rule with a 'selector' P that has been given two style declarations, i.e. two 'property:value' pairs. 'font-family' and 'font-size' are properties of the content of element P , and these properties are assigned the values of 'serif' and '1.2em' respectively. A colon ':' is the value assignment symbol in CSS, so using an equal sign '=' instead is an error and is required by the CSS specification to be ignored. Any browser that appears to honor this style is behaving improperly. For length values a 'unit' is always needed and there shall never be any space between a number and its length unit. A value given as e.g. '1.2 em' is an error and is required by the CSS specification to be ignored. Any browser that appears to honor this style is behaving improperly. A semicolon ';' between declarations is required but it's also good "rule of thumb" to put a ';' even after the last declaration. Finally, curly braces '{…}' group one or more declarations into a final CSS rule.

Question - 103 : - Why are there gaps above and below my form in IE?

Answer - 103 : - A lot of the time, when you find gaps that you can't account for, they are due the default styles of different browsers - especially the margins and padding. IE gives forms some margins above and below forms while Firefox doesn't. It's like with lists - you'll find bigger padding and margins for lists in IE than in Firefox. Paragraph margins are different, as are the margins on heading tags (h1,h2, etc). A good way to not get caught out by these problems is to set all margins and padding to zero at the top of your style sheet and then add them as and when you feel the a need for them, in that way, any margins and padding will be the same in different browsers. CSS * { margin:0; padding:0; } If one were to set Text and Link colors using a style sheet, should one also define the background colors for these elements as well? It is generally true that you should give background or background-color a value, but not necessarily a color value. E.g., if the document has a background image, you would "highlight" all links if you give them a background color. body { background-image: url(light-texture.png) #FFF; color: #000 } a:link, a:visited, a:active { color: #00F; background-color: transparent; } By setting the background-image explicitly to transparent, you lower the risk of another rule in the cascade giving links a background that would highlight them.

Question - 104 : - How do you override the underlining of hyperlinks?

Answer - 104 : - CSS has the ability to explicitly control the status of underlining for an element - even for hyperlinks. The correct way to do this in an external or document-level style sheet is: A { text-decoration: none } and within an anchor element as: link text Note: The underlining of hyperlinks is a long-standing visual convention that assists in the visual identification of active hyperlink areas. Many users expect to see hyperlinks underlined and may be confused and/or irritated if they are not used. User-defined style sheets address this user need by allowing the user to have final control over this feature. Unfortunately, wide support for this ability does not yet exist.

Question - 105 : - How do you show which page you're on (in a menu)?

Answer - 105 : - If PHP is not available to you, you could use the cascade. Put an id in your body tags and an id in each of your 'a' tags for the links. Let's say on page one you have this: CSS .... page one ... In your CSS, you can have something like this: CSS #page1 a#page1link { color:purple;

Question - 106 : - How can I specify two different sets of link colors?

Answer - 106 : - By classifying each set of links and then attaching desired color to each set. CSS: You can name set1 and set2 any way you like as long as the names are made up of letters 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. Note: to avoid conflict with user's settings a background property (background color) should also be specified together with the color property (foreground color).

Question - 107 : - How can I place multiple blocks next to each other?

Answer - 107 : - In theory, the following will produce 4 "columns":

Block 1
Block 2
Block 3
Block 4
Each "column" will occupy 25% of the screen. This relies on a correct implementation of float, which cannot be said of many legacy browsers. If you cannot accept display variances in older browsers, then it may be best to fall back to table-based solutions. 2. By making the block an inline element and then use text-align property
...
This technique depends on the incorrect implementation of text-align behavior in older browsers. It will likely cease to work in future CSS-conformant browsers, and eventually it will probably not be a viable solution.

Question - 108 : - Document Style Semantics and Specification Language (DSSSL)?

Answer - 108 : - Document Style Semantics and Specification Language is an international standard, an expression language, a styling language for associating processing (formatting and transformation) with SGML documents, for example XML.

Question - 109 : - What is Extensible Stylesheet Language (XSL)?

Answer - 109 : - XSL is a proposed styling language for formatting XML (eXtensible Markup Language) documents. The proposal was submitted to the W3C by Microsoft, Inso, and ArborText.

Question - 110 : - Which font names are available on all platforms ?

Answer - 110 : - The simple answer is "None" which is why CSS offers five generic font names as 'serif', 'sans-serif', 'cursive', 'fantasy' and 'monospace'. Never put any of these generic font names in quotes. A CSS aware browser should make a suitable choice from the available fonts in response to each of those generic names. Specifying any other font name in a www environment comes out as a suggestion only, that may or may not be acknowledged by a browser. The problem with using names of specific fonts is that there is little point in naming fonts that few users will have, so you're down to listing a few mass-market font names. This will then override any superior selection that a minority of discerning readers may have made for themselves. Note also that fonts may differ in their character repertoire, but this is often not evident from the font name itself: by selecting an inappropriate font name, you might prevent internationalized content from displaying correctly for a proportion of users.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners