+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

CSS Interview Questions and Answers

1
What is CSS?

CSS is a standard for applying style to HTML elements. This styling includes margins, positioning, fonts, colors, and so forth. The styling can apply to the complete document or be granular and apply to a specific element. Theoretically, the use of CSS promotes the separation of content and design, allowing the designer to focus on how a Web application will look while the developer(s) concentrate on the structure and functionality.
The main part of CSS is a rule. A rule consists of a selector (i.e., what will be styled) followed by a declaration (i.e., the style to be applied) that is broken into one or more properties and associated styles. In the following example, h1 is the selector, followed by the color property and the style of blue.
h1 {color: blue;}

2
Is CSS case-sensitive?

The CSS standard is not case-sensitive, but if an XHTML doctype is used, then CSS class names will be case-sensitive in some browsers. In addition, items like font families, image URLs, and other direct references with the style sheet can be case-sensitive. To be safe, you should stick with lower-case to avoid confusion or unexpected problems.

3
What are different ways to apply styles to a Web page?

There are four ways to integrate CSS into a Web page (some consider items three and four the same):

  • Inline: HTML elements may have CSS applied to them via the STYLE attribute.
  • Embedded: CSS may be embedded in a Web page by placing the code in a STYLE element within the HEAD element.
  • Linked: CSS may be placed in an external file (a simple text file containing CSS) and linked via the link element.
  • Imported: Another way to utilize external CSS files via @import.
4
What is an ID selector?

An ID selector is a name assigned to a specific style. In turn, it can be associated with one HTML element with the assigned ID. Within CSS, ID selectors are defined with the # character followed by the selector name. The name can contain characters a-z, A-Z, digits 0-9, period, hyphen, escaped characters, and so forth.
The following snippet shows the CSS example1 defined followed by the use of an HTML element's ID attribute, which pairs it with the CSS selector.
#example1: {background: blue;}
...

5
What is the difference between an ID selector and CLASS?

An ID selector identifies and sets style to only one occurrence of an element, while CLASS can be attached to any number of elements.

Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.
FOLLOW US