CSS Interview Questions and Answers for Freshers and Experienced

Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language like HTML. CSS most often used to set the visual style of web pages and user interfaces written in HTML, XHTML and XML. Along with HTML and JavaScript, CSS is a cornerstone technology used by most websites to create visually engaging webpages, user interfaces for web applications, and user interfaces for many mobile applications. Skill of CSS is very much required for entry-level as well as for senior web developer position along with HTML and Java Script. Here you will find a list of common important questions on CSS with answers. The following section consists of subjective questions and answers on CSS.

Q.1 : What is Cascading Style Sheet (CSS)?

CSS stands for Cascading Style Sheet. CSS is a style sheet language used for describing the presentation of a document written in a markup language including colors, layout, and fonts. 

It allows to control the presentation to different types of devices, such as large screens, small screens, or printers. 

CSS is independent of HTML and can be used with any markup language. The separation of HTML from CSS makes it easier to maintain web sites, share style sheets across pages, and tailor pages to different environments.

Q.2 : What is the origin of CSS?

SGML (Standard Generalized Markup Language) marked the beginning of style sheets in 1980s and CSS was developed to provide style sheets for the web.

Q.3 : What does "Cascading" means in CSS?

"Cascading" refers to the cascading order in HTML document. IF we declare 2 css file in html then by using this feature HTML will sort the declared CSS in an order to avoid the conflicts.

Q.4 : What are the different way of using or integrated CSS in Web Page?

Below are three ways of inserting a style sheet:

  1.  Inline Style Sheet   – Adding the CSS to the HTML elements.
  2.  Embedded or Internal Style Sheet – Adding the CSS styles in <style> attribute.
  3.  External Style Sheet – Adding the External CSS file to the HTML document.

Inline Style Sheet

An inline style may be used to apply a unique style for a single element.

<h1 style="color:blue;margin-left:30px;">This is a heading</h1> 

Embedded Style Sheet

Embedded or Internal styles are defined within the <style> element, inside the <head> section of an HTML page:

body {
    background-color: #ff0000;

External Style Sheet

External style sheet  is used inside the <link> element.

An external style sheet can be written in any text editor. The file should not contain any HTML tags. The style sheet file must be saved with a .css extension.

<link rel="stylesheet" type="text/css" href="mystyle.css">