1. CSS Home 2. CSS Introduction 3. CSS Versions 4. CSS Extension 5. Adv.& Disadv of CSS 6. HTML v/s CSS 7. CSS Syntax 8. CSS Selector 9. Inserting CSS file 10. Class 11. ID 12. Div 13. Font 14. Font-size 15. Font-weight 16. Font-style 17. Font-variant 18. Text 19. Text-color 20. Text-decoration 21. Text-transform 22. Text-indent 23. CSS Color 24. Web Safe Color 25. Background-image 26. Background-repeat 27. Background-position 28. Background-attachment 29. Background-size 30. Background-origin 31. CSS Box Model 32. Padding 33. Padding-top 34. Padding-right 35. Padding-bottom 36. Padding-left 37. Margin 38. Margin-top 39. Margin-right 40. Margin-bottom 41. Margin-left 42. Margin Demonstration 43. Border 44. Border-style 45. Different Border-style 46. Border-width 47. Different Border-width 48. Border-color 49. Border-radius 50. Border-collapse 51. Border-spacing 52. Border-image 53. Border-bottom 54. Border-bottom-style 55. Border-bottom-width 56. Border-bottom-color 57. Border-bottom-left-radius 58. Border-bottom-right-radius 59. Border-top 60. Border-top-style 61. Border-top-width 62. Border-top-color 63. Border-top-left-radius 64. Border-top-right-radius 65. Border-right 66. Border-right-style 67. Border-right-width 68. Border-right-color 69. Border-left 70. Border-left-style 71. Border-left-width 72. Border-left-color 73. Ex.Padding,Border,Margin 74. List Style 75. List Style-type 76. List Style-position 77. List Style-image 78. Dimension Properties 79. Width 80. Max-width 81. Min-width 82. Height 83. Max-height 84. Min-height 85. Grouping Selector 86. Nesting Selector 87. Floating 88. Position 89. Pseudo Element 90. First-letter Pseudo 91. First-line-Pseudo 92. Before & After Pseudo 93. Pseudo-class Selector 94. tag 95. Image Gallery 96. Scrollbars 97. Display Property 98. Cursor Property 99. Caption-side Property 100. Transform Property 101. Interview Question and Answer part 1 102. Interview Question and Answer part 2 103. Interview Question and Answer part 3 104. Interview Question and Answer part 4 105. Interview Question and Answer part 5 106. Interview Question and Answer part 6 107. Interview Question and Answer part 7 108. Interview Question and Answer part 8
Pr.Pg Next Pg

CSS Interview Questions and Answers Part 5


41. Which characters can CSS-names contain?

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).


42. How far can CSS be taken beyond the web page--that is, have generalized or non-web specific features for such things as page formatting or type setting?

  • Yes, it's possible to take CSS further in several directions.

  • W3C just published a new Working Draft which describes features for printing, e.g., footnotes, cross-references, and even generated indexes.

  • Another great opportunity for CSS is Web Applications. Just like documents, applications need to be styled and CSS is an intrinsic component of AJAX. The "AJAX" name sounds great.


43. What is the percentage value in 'font-size' relative to?

  • It is relative to the parent element's font-size.

  • For example, if the style sheet says:

H1 {font-size: 20pt;}

SUP {font-size: 80%;}

...then a <SUP> inside an <H1> will have a font-size of 80% times 20pt, or 16pt.


44. Do URL's have quotes or not?

  • Double or single quotes in URLs are optional.

  • The three following examples are equally valid:


BODY {background: url(Images/img1.png) blue}

BODY {background: url("Images/img1.png") blue}

BODY {background: url('Images/img1.png') blue}



45. What is Extensible Stylesheet Language (XSL)?

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.

46. What are the different border widths in CSS?

  • Each individual width value can be set to a value of specific width, thin, medium, thick or inherit.

  • A single value copies the width to all border sides.

  • Example: border-width: 5px;

  • All four borders of 5px solid.

  • If you specifies only two values, the first sets the border widthwill set it for the top and bottom, and the second sets the border widthwill set it for right and left.

  • Example: border-width: thin thick;

  • Top and bottom borders are thin.

  • Left and right border are thick.

  • If you specifies three values, the first sets the width of the top border, the second sets the width of the right and left borders, and the third sets the width of the bottom border.

  • Example: border-width: thick thin medium ;

  • Top borders is thick.

  • Right and Left borders are thin.

  • Bottom border is medium.

  • With four values, the style of each border is set individually in the order of top, right, bottom, and left. In general, missing values are inferred from the value defined for the opposite side.

  • Example: border-width: 5px thin medium thick.

  • Top borders is 5px.

  • Right border is thin.

  • Bottom border is medium.

  • Left border is thick


47. What are the CSS Text Properties?

  • The CSS Text properties are:

  • Text-align: This property is used to align text to left, right, center or justify, Possible values could be Left, Right, Center and Justify of text.

  • Text-color: This property is used to set the color of text.

  • Text-decoration: This property is used to assign or remove text decoration.

  • Text-transformation: This property is used to specify lower or uppercase for text.

  • Text-indent: This property is used to specify indentation that applies to text.


48. What are the Websafe colors?

  • Few years back, computer could display only (28i.e. 8 bits) 256 colors.

  • During same time following 216 safe web colors were used.

  • 256 216 = 40 colors left were used by system.

  • However today, most computers can display millions of colors.

  • According to your computer resolution, it will display colors as follows.


Color Bits

Total number of colors supported

4 bits

16 colors

8 bits

256 colors

16 bits

65,536 colors

24 bits

16,777,216 colors

32 bits

4,294,967,297 colors


49. What is Short Hex Code?

  • Short Hex Code is a shorter form of the six-digit notation. In this format, each digit is replicated to arrive at an equivalent six-digit value; For example: #F00 becomes #FF0000.

  • Nearly all browsers (version 3 and above, except IE3 Mac) support shorthand hex colors

  • Each hexadecimal code will be preceded by a pound or hash sign #. RGB triplets can be abbreviated if each of the Red, Green, and Blue hex pairs are the same. So when you use colors where there are three pairs, you can abbreviate each color channel using one character instead of two identical characters.

  • Browsers automatically expand these three-character colors into six by replicating the R, G, and B values


<style type="text/css">

H1{color: #F00;}

H2{color: #0F0;}

H3{color: #00F;}



50. What is RGB Values?

  • This color value is specified using the rgb( ) property. This property takes three values, one each for red, green, and blue. The value can be an integer between 0 and 255.

  • The syntax of RGB% is rgb(rrr%,ggg%,bbb%)in percentage of Red, Green and Blue.

  • NOTE: All the browsers does not support rgb() property of color so it is recommended not to use it.


<style type="text/css">


H2{color: rgb(0%,100%,0%);}

H3{color: rgb(0%,0%,100%);}


Pr.Pg border                                              Next Pg