CSS

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 2

 

11. What is difference between HTML and CSS?

HTML

CSS

It stands for Hyper Text Markup Language is a widely accepted web-design formatting language.

It stands for Cascading Style Sheets is used to format HTML content.

It is used to create web pages and other information that can be displayed in a web browser.

CSS does not create anything. Instead, it decorates, aligns and positions elements in HTML. CSS takes the normal HTML output and adds a few rules to how it's actually displayed in browser.

HTML is written with help of HTML elements consisting of tags enclosed in angle brackets like <html>,<br>,<hr> and so on. Most HTML tags come in pairs like <head> and </head>, <h1> and <h2>. The first tag in a pair is the start tag, and the second tag is the end tags.

Sometimes times are also known as opening and closing tags. While some tags are empty tags such as <br>, <img>.

HTML is capable of doing many thing, while certain thing are deprived. CSS can edit things such as element width and height, background color, border, alignment, and actual visibility.

Web browsers read HTML documents and it display content on the webpage. Browser does not display HTML tags.

The CSS syntax consists of a set of rules. These rules have 3 parts: a selector, a property, and a value.

 

HTML elements are building block of all websites.

CSS was added to HTML 4.0 to make website uniform with ease. CSS is used to define the appearance and layout of text and other materials.

HTML is plain text file, it is written between <html> and </html> tags. It further divides web page into <head> …</head> and <body> …. </body> elements.

The text between <html> and </html> describes the web page. Text between <head> and </head> is used to specify page related information. Finally the text between <body> and </body> is used to write visible page content.

CSS can be incorporated into a webpage using Internal markup, i.e. in the <head>; in <style> tags, or external markup from a "external .css" file.

 

12. What is external Style Sheet? How to link?

  • External Style Sheet is a template/document/file containing style information which can be linked with any number of HTML documents.

  • This is a very convenient way of formatting the entire site as well as restyling it by editing just one file. The file is linked with HTML documents via the LINK element inside the HEAD element.

  • Files containing style information must have extension .css, e.g. style.css.

<HEAD> <LINK REL=STYLESHEET HREF="style.css" TYPE="text/css"> </HEAD>

 

13. What is embedded style? How to link?

  • Embedded style is the style attached to one specific document. The style information is specified as a content of the STYLE element inside the HEAD element and will apply to the entire document.

  • Note: The styling rules are written as a HTML comment, that is, between to hide the content in browsers without CSS support which would otherwise be displayed.

 

14. What is inline style? How to link?

  • Inline style is the style attached to one specific element.

  • The style is specified directly in the start tag as a value of the STYLE attribute and will apply exclusively to this specific element occurance.

 

15. What is imported Style Sheet? How to link?

  • Imported Style Sheet is a sheet that can be imported to (combined with) another sheet. This allows creating one main sheet containing declarations that apply to the whole site and partial sheets containing declarations that apply to specific elements (or documents) that may require additional styling. By importing partial sheets to the main sheet a number of sources can be combined into one.

  • To import a style sheet or style sheets include the @import notation or notations in the STYLE element. The @import notations must come before any other declaration. If more than one sheet is imported they will cascade in order they are imported – the last imported sheet will override the next last; the next last will override the second last, and so on. If the imported style is in conflict with the rules declared in the main sheet then it will be overridden.

 

16. What is alternate Style Sheet? How to link?

  • 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,

  • Example:

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

  • Example:

<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

  • Example:

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

17. What is Class?

  • In CSS, The class selector is used to specify a style for a group of elements.

  • This allows you to set a particular style for many HTML elements with the same class.

  • You declare a CSS class by using a dot (.) followed by the class name. After declaring the class name you simply enter the properties/values that you want to assign to your class.

Syntax:

.class-name { property: value; }

  • Example: For example, you can specify two paragraphs to have different color text:

p.green {color: green;}

p.blue {color: blue;}

  • To specify a tag as part of a class, you have to use the class attribute within that tag in HTML as follow:

<p class="green">This text is green</p>

<p class="blue">This text is blue</p>

18. What is grouping?

  • Grouping is gathering into a comma separated list two or more selectors that share the same style or into a semicolon separated list two or more declarations that are attached to the same selector

  • Example: The selectors LI, P with class name .first and class .footnote share the same style, e.g.:

LI {font-style: italic}

P.first {font-style: italic}

.footnote {font-style: italic}

  • To reduce the size of style sheets and also save some typing time they can all be grouped in one list.

  • LI, P.first, .footnote {font-style: italic}

19. What is selector?

  • CSS selector is equivalent of HTML element(s). It is a string identifying to which element(s) the corresponding declaration(s) will apply and as such the link between the HTML document and the style sheet.

  • For example in P {text-indent: 10pt} the selector is P and is called type selector as it matches all instances of this element type in the document.

  • in P, UL {text-indent: 10pt} the selector is P and UL (see grouping); in .class {text-indent: 10pt} the selector is .class (see class selector).

20. What is ID selector?

  • Similar to class selectors, id selectors enable you to select an element based on the id attribute.

  • While the class selector used a period (.), the id selector relies on a hash (#).

  • In this rule, renders the content in red for every element with id attribute set to red in our document.

#red {color: ff0000;}

  • Example: We can make it a bit more particular. For example, following rule renders the content in red for only <h1> elements with id attribute set to red.

 

h1#red {color: ff0000;}

Pr.Pg border                                              Next Pg