CSS Interview Questions

Every business is trying to make websites that are user engaging. An attractive website increases the engagement time as the customer spends some time exploring it. Thus, every company is hiring developers who can make that happen. If you are a CSS aspirant is applying for the post of CSS developer, make sure you go through the smart compilation of these interview questions that can help you achieve your dream job.

Read Best CSS interview questions

Here are some of the CSS interview questions:

#1 Describe ‘rule set’?

It is an instruction that tells browser on how to render a specific element on the HTML page. It consists of a selector with a declaration block that follows. Rule set: Selectors can be attached to other selectors to be identified by rule set.

It has two parts:

  • Selector, e.g. R and
  • Declaration block {text-indent: 11pt}

#2 What is CSS?

Cascading style sheets or CSS is a web designing language simple for HTML elements. The application is commonly known as XHTML. It is basically used to simplify the process and make the web page look presentable.

#3 Enlist the media types CSS allows?

Media is one of the most important features of CSS. Media renders the design and customization of documents. By applying media control over the external style sheets, they can be retrieved and used by loading it from the network. Some of the media types are:
  • All – for all devices
  • Aural – speech synthesizers
  • Braille – feedback devices
  • Embossed – paged braille printers
  • Handheld – typically small screen, limitation of bandwidth
  • Projection – basically for projectors
  • Tv – television type devices
  • Screen – color computer screens

#4 Compare RGB values with Hexadecimal color codes?

A color can be specified in two ways:
  • A color is represented by 6 characters i.e. hexadecimal color coding. It is a combination of numbers and letters and is preceded by #. e.g.: g {color: #00cjfi}
  • A mixture of red, green and blue represents a color. The value of a color can also be specified.

e.g.: rgb(r,g,b):
In this type the values can be in between the integers 0 and 255. rgb(r%,g%,b%): red, green and blue percentage is shown.

#5 What are the limitations of CSS?

There are several limitations of CSS such as:
  • CSS can’t fulfill turning completeness hence, it can never perform logical like ‘if/else’, for/while, etc, or arithmetical tasks
  • One cannot read files using CSS
  • It cannot provide total control over document display and allows the contents of the page to come through whatever the browser is used.
  • Ascending by selectors is not possible
  • Limitations of vertical control
  • No expressions as it is a text-based coding language
  • No column declaration
  • Pseudo-class not controlled by dynamic behavior
  • Rules, styles, targeting specific text not possible

#6 Enlist the various Media types used?

Different media has different properties as they are case insensitive.
They are:
  • Aural – for sound synthesizers and speech
  • Print – gives a preview of the content when printed
  • Projection- projects the CSS on projectors.
  • Handheld- uses handheld devices.
  • Screen- computers and laptop screens.

#7 What is the purpose of the z-index and how is it used?

The z-index helps specify the stack order of positioned elements that may overlap one another. The z-index default value is zero, and can take on either a positive or negative number.

An element with a higher z-index is always stacked above than a lower index.

Z-Index can take the following values:

  • Auto: Sets the stack order equal to its parents.
  • Number: Orders the stack order.
  • Initial: Sets this property to its default value (0).
  • Inherit: Inherits this property from its parent element.

#8 Differentiate logical tags from physical tags?

There are several pointers that make local tags different from physical tags:
Physical TagsLocal Tags
Physical tags are used to indicate how a particular character is to be formattedlogical tags are used to indicate by the visually impaired and put emphasis on the text.
Physical tags are also referred to as presentational mark-upLogical tags are useless for appearances
Physical tags are newer versionsLogical tags are old and concentrate on content

#9 What is the usage of Class selector?

A name preceded by a full stop is considered as a class selector in CSS. Selectors that are unique to a specific style, are called CLASS selectors. Declaration of style and association with HTML can be made through this. An ID identifies a single element whereas a class identifies more than one element.

Syntax for the class selector:

Classname:it can be A-Z, a-z or digits.

.top {font: 14em ;} //class selector
<Body class= "top"> //this class is associated with element </body>

#10 What are the advantages of CSS?

There are a number of advantages of CSS,
  • It gives lots of flexibility for setting the properties of the element
  • Easy maintenance
  • It allows separation of content of the HTML document from the style and layout of the content basically
  • Loading of pages at a faster pace
  • Compatibility with multiple device
  • Increases the website’s adaptability and makes it compatible to future browsers

#11 Discuss the merits and demerits of Embedded Style Sheets?

There are several merits and demerits of embedded style sheets:
Merits of Embedded Style Sheets:
  • Multiple tag types can be created in a single document.
  • Styles, in complex situations, can be applied by using Selector and Grouping methods.
  • Extra download is unnecessary.

Demerits of Embedded Style Sheets:

  • Multiple documents cannot be controlled.

#12 What is CSS Box Model and what are its elements?

The CSS box defines the design and the layout of elements of CSS. The several elements are:

Margin: transparent area outside border
Border: the padding and content option with a border around it is shown.
Padding: Space is around content. Padding is transparent.
Content: box where text and images appear.

	width: 300px;
	border: 25px solid  yellow;
	padding: 25px;
	margin:  25px;

#13 Enlist the various fonts’ attributes?

They are:
  • Font-style
  • Font-variant
  • Font-weight
  • Font-size/line-height
  • Font-family
  • Caption
  • Icon

#14 In how many ways can a CSS be integrated as a web page?

CSS can be integrated in three ways:

  • Inline: term is used when the CSS code have attribute of HTML elements
    <p style="colour:skyblue;"> hello world!</p>
  • External: separate CSS file is created in the workspace and later linking them in every web page that is created
      <link rel="text/css"
  • Internal: the head element of the web page has internal CSS implemented in it

#15 What is Pseudo-elements?

Pseudo-elements are keyword added to the selector that allows one o style a specific part of the selected element. CSS in used to apply styles in HTML mark-up. In some cases when extra mark-up or styling is not possible for the document, then there is a feature available in CSS known as pseudo-elements. It will allow extra mark-up to the document without disturbing the actual document. It can be used for;
  1. To style the first letter, line or element
  2. To insert a content


Selector: :pseudo-element {

property1 :value;
property2 :value;

Ask a Question