Hiring managers expect a mastery of these topics even for the most junior developers, which is why it is so important to be prepared to answer CSS interview questions when they are asked. There are some topics like React.js and MySQL that are perfectly acceptable to be mastering even as a mid- or senior-level developer. However, HTML and CSS are not some of those topics. We hope you enjoy our list of some common technical questions that you should be prepared to answer during your next interview.

Person sitting in front of laptop

What does the acronym CSS stand for?

Cascading style sheets are the words used to make up the acronym CSS. Before CSS, most styling was contained within the HTML tags of the document. CSS lets you describe the design, layout, and style of the HTML document.

Why is the word “cascading” very important in CSS?

CSS follows an order of importance. By default, what is most important is what was mentioned first in the program. Therefore, instructions cascade downward by importance, much like a waterfall. That cascade can be overwritten by selecting an element and applying unique styling. For example, if you first apply a background color of “red” to an HTML page and then later give it a background color of “blue”, then the background color will be the value that came last – “blue” – as the programming cascades downward. 

The Web Developer Bootcamp 2024

Last Updated March 2024

  • 726 lectures
  • All Levels
4.6 (273,215)

10 Hours of React just added. Become a Developer With ONE course – HTML, CSS, JavaScript, React, Node, MongoDB and More! | By Colt Steele

Explore Course

How would you describe CSS to someone who’s never used it before? 

The easiest way to describe CSS might be to avoid “cascading style sheets” and instead refer to it as the “color, size, and shape” of elements on a web page. All of the colors, sizes, and shapes amount to the styling of a web document.

What is the relationship between HTML and CSS?

HTML elements are the foundation of any web document. Many HTML tags come with some CSS styles by default. We can alter that styling by applying CSS attributes and values to the elements.

What is the relationship between HTML, CSS, and JavaScript?

HTML elements can be styled with CSS, and CSS does include some dynamic attributes as well as animations. However, any advanced programming for the styling of the site will need to be done using JavaScript.

What’s the most current version of CSS and when was it released?

CSS 4.0 in 2017 and CSS 4.15 12/2020. However, that versioning is very much a misnomer, and it’s to be said that CSS4 does not exist — per the web. Currently, “CSS3” is used in conjunction with “HTML5” and JavaScript to create modern web page experiences.

What are three possible ways to apply CSS to an Index HTML document?

Inline: Giving style attributes and values directly to HTML elements in the document. Typically, inline styling is to be avoided because it can make it very difficult to debug across multiple device viewports.

Internal: Styling within the <head> of an HTML document and contained within <style> tags. Internal styling is usually used in a component-based architecture, such as React.js, to apply styling to individual components as they’re rendered across the development.

Imported: CSS styling imported into an HTML document from an outside `.css` file. This is the most common type of CSS usage in web development projects as it adheres to the “separation of concerns” best practice in which we abstract away potentially confusing coding for the sake of the human developer and not the machine’s computations.

Where would a `<style>` tag go in an HTML document?

If the header of the project called for internal styling or after an opening <head> and before a closing </head> tag. The <style> tag opens and closes </style>. Inside of the <style> tag, we use the CSS ruleset to isolate elements, apply attributes, and define values.

What is the difference between an attribute and a value in CSS?

Attributes are pre-scripted properties that alter the styling of HTML elements. Values are applied to attributes to receive the desired styling.

How are the attributes in a <h1> tag different from those in an <h4> tag?

An h1 will render at 32 pixels and h4 at 16 pixels. These values are in pixels, an absolute length, which will not scale depending on the device. An h1 element will be 32 pixels on a tiny smartphone as well as on an ultra-wide television.

How are selectors used?

Selectors are used to tell the browser which element to apply certain styles to. Some HTML tags have no styling by default, but many like <h1> tags and list tags do have styling by default. Other elements, however, may get custom ID selectors or query selectors to target in on them and apply specific styling during a project.

What is an id selector?

This selector uses the `id` element to specify an element within the HTML document. Each `id` should be unique so that there is no confusion when applying these very specific stylings.

What is a query selector?

A query selector, like an id selector, is used to isolate a specific element within an HTML index by using a `querySelector()` method to return the very first element found. Unlike an id selector, you can also use the `querySelectorAll()` method to find all elements with that query and order them as an array.

What is the CSS “ruleset” for isolating elements and giving them attributes?

The entire set of rules that govern applying CSS to an HTML document. These include knowledge of selector, pseudo-class, pseudo-element, declaration block, declaration, attributes, values, and keywords used in modern web development front-end styling. 

Detailed view of CSS ruleset including selector, property, value, and declaration.

What are the two types of length units?

Relative length, like em and xm, are units that specify a length relative to other length properties. On the contrary, absolute length units are fixed in relation to each other, like pixels or inches.

What are pseudo elements and can you name any?

Pseudo elements are keywords added to a selector that lets you style a specific part of the selected element. Some examples are ` ::after` and `::before`.

What are pseudo classes and can you name any?

Pseudo classes define the special state of an element. The state of an element can be changed due to events or interactions from users. Some examples include: hover and: active to trigger actions when an element has the cursor hovering over it or when an element has been toggled into “active”.

Explain the difference between margin and padding.

Margin is the space outside the border, and padding is the space between the element and the border. We can think of the HTML element as a picture on the wall with its own height and width. In that case, then the padding would be the amount of space between the edge of the picture and the edge of the picture frame. More, in that case, the margin could be thought of as the amount of space between the pictures.

How do we use the box model with CSS?

Each element is given a size, padding, and margin — sometimes border — for spacing around the layout design. The goal is to design elements to behave like blocks that will break off into new lines, extend in the inline direction, maintain relative height/width, and other elements will remain at a distance.

What is the difference between position: absolute and position: relative?

Absolute places an element relative in a position and will change all of the elements around it. Relative position will place an element into a position without changing the elements around it.

How are colors defined as values?

CSS has a number of case-sensitive color names that can be given as values, such as “dodgerblue” and “rebeccapurple”. RGB, HEX, HSL, RGBA, and HSLA values are also acceptable when defining a color.

Which attribute is used to style borders and what values can it be given?

The `Border-style` attribute allows developers to define the type of border on all four sides of an HTML element. Those styles include dotted, dashed, solid, and others.

Which attribute is used to give a color to a text?

We use the `color` attribute to name the color of text within an element. The value can be the named colors that are included with CSS or any RGB, HEX, HSL, RGBA, or HSLA value.

Which attribute is used to give a color to a background?

We use the `background-color`attribute to name the color of the background of an element. The value can be the named colors that are included with CSS or any RGB, HEX, HSL, RGBA, or HSLA value.

What is the z-index?

As the x-axis goes left to right and the y-axis goes top to bottom, there’s also a z-axis that goes forward to back. Negative numbers can be thought of as “farther” away, and larger numbers can be thought of as “closer” to the user.

What is the overflow attribute and what are some possible values?

The overflow attribute defines what happens to content that doesn’t fit cleanly in the browser upon loading. Specifies whether to clip content or not by using values like “scroll” to add a scroll bar with access to the whole page or “hidden” to cut off any remainder on the rendering. 

What are some CSS units?

All CSS units are expressions of “length” in one direction or another. There are many “length” values like width, margin, padding, font-size, etc. Each of these lengths is followed by a number or some assigned value as their unit of measurement in the project. 

Which attribute can give an element rounded corners?

The attribute `border-radius` allows developers to apply rounded corners and edges to their HTML elements. The value can be the number of pixels, a percentage of a circle, or any other CSS unit to be used in the radial equation.

Why use a box shadow effect?

The box shadow effect will give a 3D appearance, as if the element is floating off the page by presenting a shadow on the bottom and, typically, to the right of the element and no shadow whatsoever across the top and left side of the element. Thus, an effect as though a light is shining on the element from an angle, making it appear to float on the page without the need for any JavaScript or design libraries.

Which unit is used to measure animations in CSS?

Keyframes control each and every step of an animation as it is occurring on the page. These can be triggered with the `@keyframes` syntax. Each keyframe can be thought of as a waypoint along the way from the initial position of an element to its final position at the end of the animation.

How are “tooltips” used?

They appear when the mouse hovers over to suggest next actions. Tooltips are very informative to users and helpful in controlling the user experience by giving them directions on how an element being hovered over is to be used.

What is pagination, and how is it accomplished with CSS?

Pagination is when you present a large volume of data as separate pages to make it more digestible instead of an extremely long scroll. Usually, there are page numbers at the bottom of the site.

Explain how to use variables in your CSS.

We have variables in CSS, just like in JavaScript and in other languages. However, we don’t need to set aside some room in data storage by declaring a variable like `const` in JavaScript, nor give it a type declaration like `string` in TypeScript. To use variables in CSS, begin by defining the variables like `:root{–blue: dodgerblue}` and then name them in the CSS like `body{background-color: var(–blue)};` Note the original declaration inside of :root{} as well as the double dash `–`.

What is flexbox?

The Flexible Box Layout Module makes it easier to design flexible responsive layout structures without using float or positioning. Using flexible heights and widths allows elements to align within a space and evenly distribute themselves depending on the device and the browser. It was first introduced in 2009 and has enjoyed support from all modern browsers as the industry has further embraced mobile-first responsive web design.

What is responsive web design?

Responsive web design is focused on creating web experiences that look great on all devices, including small cellular devices, medium-sized tablets, large desktop screens, and even ultra-wide televisions, as internet connectivity becomes ubiquitous with all electronic devices.

Truly responsive web design uses only HTML and CSS without relying on JavaScript or other technologies to create the front-end experience. Media queries are available to apply unique styling depending on the device viewport dimensions.

There is no third-party software or JavaScript in the creation of responsive web design. In web development, smaller file sizes are always preferred because internet connectivity can differ so greatly from one region of the world to the other and our web pages are made for *everyone* in the world. Using JavaScript or some other software to create a responsive web experience when all the tools are already included in HTML and CSS would create a bloated app development that wouldn’t render as quickly for users without very fast internet connectivity.

How can we use the Grid layout? 

The CSS Grid Layout Module offers a grid-based layout system. It uses rows and columns to create web pages without using floating elements and flexible positioning. The CSS Grid pattern is excellent at dividing a page into primary sections by prioritizing their size, position, and layer. The elements of the grid are composed of HTML elements and scale with viewport size.

What is Canvas?

The HTML <canvas> element is used to draw 2D graphics using JavaScript. Within canvas, we have access to both HTML and CSS syntax to create and edit very graphical user experiences. This HTML element can be used to create intricate drawings, photos, and animations. Some of the features include transformations, pixel manipulations, and image compositing. All major browsers support the <canvas> element.

What is Bootstrap?

Bootstrap is a free and open-source CSS framework directed at responsive, mobile-first, front-end web development. It contains HTML, CSS, and (optionally) JavaScript-based design templates for typography, forms, buttons, navigation, and other interface components. The primary advantage of Bootstrap is that it is mobile-responsive out of the box so that we don’t have to write media queries for all cellular devices, tablets, and desktop computers. However, Bootstrap is extremely popular and easily recognizable, so it should be avoided if a developer wants a unique experience.

What is Tailwind CSS?

A utility-first CSS framework packed with classes like flex, pt-4, text-center, and rotate-90 that can be composed to build any design directly in your markup. Like Bootstrap, it is mobile-responsive first, thus saving developers tons of time. Unlike Bootstrap, however, it is an open framework that encourages developing unique experiences from the very beginning.

What is SCSS?

Stylesheets are getting larger, more complex, and harder to maintain. This is where an SCSS preprocessor can help. SCSS lets you use features that do not exist in CSS, like variables, nested rules, mixins, imports, inheritance, built-in functions, and other stuff. SCSS is excellent for larger projects in which many different pages may share a similar style or theme. 

That’s it for our list of 40 CSS interview questions that you should know before your next big interview! We hope you found it useful and learned something new to help create an amazing online web experience for your next project! Please don’t forget to check out our Top CSS Courses or this free guide on Flexbox vs. Grid to continue learning front-end styling and advance your web development career!

Page Last Updated: May 2022

Top courses in CSS

The HTML & CSS Bootcamp 2024 Edition
Colt Steele
4.8 (2,490)
Highest Rated
Advanced CSS and Sass: Flexbox, Grid, Animations and More!
Jonas Schmedtmann
4.7 (43,889)
CSS - The Complete Guide 2024 (incl. Flexbox, Grid & Sass)
Academind by Maximilian Schwarzmüller, Maximilian Schwarzmüller, Manuel Lorenz
4.8 (18,405)
50 Projects In 50 Days - HTML, CSS & JavaScript
Brad Traversy, Florin Pop
4.7 (11,661)
Build Responsive Real-World Websites with HTML and CSS
Jonas Schmedtmann
4.7 (106,938)
CSS Bootcamp - Master CSS (CSS Grid / CSS Flexbox)
Code And Create, George Lomidze, Lasha Nozadze
4.5 (1,346)
Build Websites from Scratch with HTML & CSS
Brad Hussey, Code College
4.6 (14,598)
HTML and CSS for Beginners - Build a Website & Launch ONLINE
Edwin Diaz, Coding Faculty Solutions
4.4 (36,216)

More CSS Courses

CSS students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo