CSS vs CSS3


CSS vs CSS3 Interview with follow-up questions

1. What are the main differences between CSS and CSS3?

Technically, "CSS3" is not a single specification. Starting with CSS3, the CSS Working Group split development into modules (Selectors, Color, Backgrounds, Flexbox, Grid, Animations, etc.), each with its own version number and specification. So there is no monolithic "CSS3" — there are dozens of CSS modules at various levels. In 2026, interviewers use "CSS3" as shorthand for features added after CSS2.1, and "modern CSS" for the wave of features added since roughly 2020.

That said, the key improvements that "CSS3" brought over CSS2.1:

Selectors — attribute selectors with substring matching (^=, $=, *=), :nth-child(), :nth-of-type(), :not(), :checked, :target, :enabled/:disabled.

Visual effectsborder-radius (rounded corners without images), box-shadow, text-shadow, opacity, background-size, multiple backgrounds on a single element.

Transforms and transitionstransform: rotate(), scale(), translate(), skew(). transition for smooth state changes. These replaced JavaScript-based animation in many cases.

Animations@keyframes with animation properties for self-running, declarative animations.

Media queries@media (max-width: 768px) enabled responsive design without JavaScript viewport detection.

Layout models — Flexbox and Grid (technically later in the CSS3 era but part of the CSS3 module set) revolutionized layout, replacing float-based hacks.

Web fonts@font-face allowed custom fonts without JavaScript font loaders.

Variables — CSS custom properties (--property-name: value; var(--property-name)) removed the need for Sass variables for many use cases.

What's happened since CSS3: Container queries (@container), :has(), CSS nesting, @layer, oklch() color, color-mix(), scroll-driven animations, and @starting-style. These are often grouped as "modern CSS" rather than CSS3.

↑ Back to top

Follow-up 1

Can you give an example of a feature that is only available in CSS3?

One example of a feature that is only available in CSS3 is the border-radius property. This property allows you to create rounded corners on elements, which was not possible with previous versions of CSS.

Here is an example of how to use the border-radius property:

.rounded-box {
  border-radius: 10px;
}

Follow-up 2

How does the introduction of CSS3 improve web design and development?

The introduction of CSS3 improves web design and development in several ways:

  1. More Styling Options: CSS3 introduces new properties and features that allow for more advanced and creative styling options. This includes properties for gradients, shadows, animations, and more.

  2. Responsive Design: CSS3 introduces media queries, which allow for the creation of responsive designs that adapt to different screen sizes and devices. This improves the user experience and makes websites more accessible.

  3. Layout Control: CSS3 introduces new layout models like Flexbox and Grid Layout, which provide more control over the positioning and alignment of elements. This makes it easier to create complex and responsive layouts.

  4. Better Performance: CSS3 introduces hardware acceleration for animations and transitions, which improves performance and provides a smoother user experience.

Overall, the introduction of CSS3 enhances the visual appeal, functionality, and performance of websites.

Follow-up 3

What are some challenges you might face when working with CSS3?

When working with CSS3, some challenges you might face include:

  1. Browser Compatibility: CSS3 introduces new features and properties that may not be supported by older browsers. This can lead to inconsistencies in the appearance of your website across different browsers.

  2. Learning Curve: CSS3 introduces new concepts and techniques that may require additional learning and practice. It can take time to become familiar with the new features and understand how to use them effectively.

  3. Performance Considerations: Some CSS3 features, such as animations and transitions, can impact the performance of your website if not used judiciously. It is important to optimize your CSS3 code to ensure smooth performance.

  4. Vendor Prefixes: CSS3 features often require vendor prefixes to ensure compatibility with different browsers. This can result in writing additional code and maintaining multiple versions of the same property.

By being aware of these challenges and staying up-to-date with best practices, you can overcome them and make the most of CSS3 in your web development projects.

Follow-up 4

Can you explain how media queries work in CSS3?

Media queries in CSS3 allow you to apply different styles based on the characteristics of the device or viewport. They are used to create responsive designs that adapt to different screen sizes and devices.

Media queries consist of a media type and one or more expressions, which define the conditions under which the styles should be applied. The media type can be a specific device type (e.g., screen, print, handheld) or a media feature (e.g., width, height, orientation).

Here is an example of a media query that applies different styles for screens with a maximum width of 768 pixels:

@media screen and (max-width: 768px) {
  /* Styles for screens with a maximum width of 768 pixels */
}

You can also combine multiple media queries using logical operators like 'and' and 'or' to create more complex conditions.

Media queries are a powerful tool for creating responsive designs and ensuring that your website looks and functions well on different devices.

2. What are some new features introduced in CSS3?

CSS3 and subsequent CSS modules introduced features that fundamentally changed how CSS is written. The most important to cover in a 2026 interview:

Selectors Level 3+

  • :nth-child(an+b) expressions for targeting specific children by position
  • :not() negation pseudo-class
  • Attribute substring selectors ([attr^=], [attr$=], [attr*=])
  • :has() (now widely supported) — selects a parent based on what it contains: li:has(> img) selects list items with a direct image child

Box model and visual

  • border-radius for rounded corners
  • box-shadow and text-shadow
  • box-sizing: border-box — makes width include padding and border, eliminating a common source of layout bugs
  • Multiple backgrounds on a single element

Transforms and transitions

  • transform with rotate(), scale(), translate(), skew(), and 3D variants
  • transition for animated state changes
  • @keyframes and animation for self-contained, non-interactive animations

Media queries

  • @media rules for responsive layout based on viewport width, height, orientation, resolution, and (via Media Queries Level 5) user preferences like prefers-color-scheme and prefers-reduced-motion

Layout

  • Flexbox — one-dimensional alignment and distribution
  • CSS Grid — two-dimensional layout with rows and columns; subgrid extends this to nested components

Web fonts

  • @font-face with multiple format sources (woff2, woff, etc.)

Custom properties (CSS variables)

  • --name: value declarations and var(--name) usage — cascade-aware, JavaScript-readable, and far more powerful than Sass variables

Modern additions (post-CSS3, now baseline)

  • Container queries (@container) — respond to a component's container size rather than the viewport
  • @layer — explicitly orders cascade layers, solving specificity conflicts without !important
  • Native CSS nesting — nest selectors without a preprocessor
  • color-mix() and oklch() — wide-gamut color and programmatic color blending
  • Scroll-driven animations — animation-timeline: scroll() triggers animations based on scroll position, no JavaScript needed
↑ Back to top

Follow-up 1

Can you explain how to use the transition property in CSS3?

The transition property in CSS3 allows you to smoothly animate changes in CSS properties over a specified duration. Here's an example:

.element {
  transition: background-color 1s ease-in-out;
}

.element:hover {
  background-color: red;
}

In this example, when you hover over the element, the background color will transition from its initial state to red over a duration of 1 second, with an ease-in-out timing function. You can specify multiple properties to transition by separating them with commas.

Follow-up 2

How does the border-radius property enhance the design of a webpage?

The border-radius property in CSS3 allows you to round the corners of an element. This can enhance the design of a webpage by giving it a more modern and visually appealing look. Here's an example:

.element {
  border-radius: 10px;
}

In this example, the corners of the element will be rounded with a radius of 10 pixels. You can also specify different radii for each corner using the border-top-left-radius, border-top-right-radius, border-bottom-left-radius, and border-bottom-right-radius properties.

Follow-up 3

What is the purpose of the animation property in CSS3?

The animation property in CSS3 allows you to create complex animations by specifying keyframes and animation properties. Here's an example:

@keyframes slide-in {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(0); }
}

.element {
  animation: slide-in 1s ease-in-out;
}

In this example, the element will slide in from the left side of the screen to its original position over a duration of 1 second, with an ease-in-out timing function. The @keyframes rule defines the keyframes for the animation, and the animation property specifies the animation name, duration, and timing function.

Follow-up 4

Can you give an example of how to use the transform property in CSS3?

The transform property in CSS3 allows you to apply various transformations to an element, such as scaling, rotating, skewing, and translating. Here's an example:

.element {
  transform: rotate(45deg) scale(1.5);
}

In this example, the element will be rotated 45 degrees clockwise and scaled to 1.5 times its original size. You can combine multiple transformations by separating them with spaces. The transform property also supports 3D transformations and matrix transformations for more advanced effects.

3. How does CSS3 improve the process of creating responsive designs?

CSS3 and its successor modules introduced the core tools that make responsive design practical in CSS, without needing JavaScript to detect viewport size or swap stylesheets.

Media queries are the foundation. They conditionally apply CSS rules based on viewport characteristics:

@media (max-width: 768px) {
  .sidebar { display: none; }
}
@media (prefers-color-scheme: dark) {
  body { background: #111; color: #eee; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

Level 5 media queries added user preference queries, enabling dark mode and motion accessibility without JavaScript.

Flexbox handles one-dimensional layouts — rows or columns — and makes items that wrap, distribute space, and align themselves automatically:

.nav { display: flex; gap: 1rem; flex-wrap: wrap; }

Items reorder and wrap naturally across breakpoints, often eliminating the need for breakpoint-specific rules.

CSS Grid handles two-dimensional layouts. auto-fill and minmax() create truly intrinsic responsive layouts that adapt without explicit breakpoints:

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }

Fluid typography with clamp() scales font size between a minimum and maximum based on viewport width with no JavaScript:

h1 { font-size: clamp(1.5rem, 4vw, 3rem); }

Container queries (now baseline) — the limitation of media queries is that they respond to the viewport, not the element's context. Container queries respond to the component's own container:

@container (min-width: 400px) {
  .card { flex-direction: row; }
}

This makes components truly portable — they adapt to wherever they're placed, not just to the viewport size.

aspect-ratio — maintains proportional dimensions without the old padding-top hack:

.video-wrapper { aspect-ratio: 16 / 9; }

The modern responsive design workflow relies on Flexbox and Grid for layout, clamp() for typography, container queries for component-level adaptation, and media queries for global breakpoints and user preferences.

↑ Back to top

Follow-up 1

Can you explain how media queries are used in responsive design?

Media queries are a key feature of CSS3 that are used in responsive design to apply different styles based on the characteristics of the device or viewport. Media queries allow developers to specify different CSS rules that will be applied only if certain conditions are met. These conditions can include the width and height of the viewport, the device's orientation, the device's resolution, and more.

For example, a media query can be used to apply different styles to a webpage when it is viewed on a mobile device compared to a desktop computer. By using media queries, developers can create responsive layouts that adapt to different screen sizes and orientations, providing a better user experience on a wide range of devices.

Here is an example of a media query that applies different styles when the viewport width is less than 600 pixels:

@media (max-width: 600px) {
  /* Styles for small screens */
}

Follow-up 2

What is the role of the viewport meta tag in responsive design?

The viewport meta tag is an HTML meta tag that plays a crucial role in responsive design. It allows developers to control how a webpage is displayed on different devices and screen sizes.

By using the viewport meta tag, developers can specify the width and initial scale of the viewport, which affects how the webpage is rendered on the device. This is important for responsive design because it allows developers to ensure that the webpage is displayed correctly and optimally on different devices, regardless of their screen size or resolution.

Here is an example of a viewport meta tag that sets the width of the viewport to the device's width and disables the initial scale:


Follow-up 3

How does CSS3 support mobile-first design?

CSS3 supports mobile-first design by providing features and techniques that prioritize the design and development of mobile-friendly websites and applications. Mobile-first design is an approach where the design and development process starts with the mobile version of a website or application, and then progressively enhances it for larger screens.

CSS3 supports mobile-first design in several ways:

  1. Media Queries: CSS3 introduces media queries, which allow developers to apply different styles based on the characteristics of the device or viewport. By using media queries, developers can create styles specifically for mobile devices and then add additional styles for larger screens.

  2. Flexible Box Layout: CSS3's flexbox layout model makes it easier to create flexible and responsive layouts. With flexbox, developers can easily align and distribute elements within a container, which is particularly useful for mobile-first design where the layout needs to adapt to different screen sizes.

  3. Grid Layout: CSS3's grid layout model provides a powerful way to create complex and responsive grid-based layouts. With grid layout, developers can define rows and columns and easily position elements within the grid, making it easier to create responsive designs for mobile-first approaches.

Overall, CSS3 provides the necessary tools and techniques to support mobile-first design and create mobile-friendly websites and applications.

Follow-up 4

Can you give an example of a CSS3 feature that is particularly useful for responsive design?

One CSS3 feature that is particularly useful for responsive design is the media query feature. Media queries allow developers to apply different styles based on the characteristics of the device or viewport, making it possible to create responsive layouts that adapt to different screen sizes and orientations.

Here is an example of a media query that applies different styles when the viewport width is less than 600 pixels:

@media (max-width: 600px) {
  /* Styles for small screens */
}

By using media queries, developers can create responsive designs that provide a better user experience on a wide range of devices, from small mobile screens to large desktop monitors.

4. What is the role of CSS3 in modern web development?

CSS (evolving continuously from CSS3 through the current modular specification) is the primary tool for visual presentation on the web. In 2026, its role in modern web development has expanded well beyond colors and fonts.

Layout system — Flexbox and CSS Grid have replaced float-based and table-based layout hacks. Grid in particular handles complex two-dimensional page structures natively. Subgrid allows nested elements to align to a parent grid, solving a long-standing problem in component-based designs.

Design systems and theming — CSS custom properties enable scalable, token-based design systems. Variables cascade, can be scoped to components or themes, and are readable and writable from JavaScript in real time, enabling dynamic theming (dark mode, user color preferences) without page reloads.

Responsive and adaptive design — media queries handle global breakpoints and user preferences (prefers-color-scheme, prefers-reduced-motion). Container queries handle component-level adaptation. Together they enable designs that respond both to the viewport and to component context.

Animation and motion — CSS transitions and @keyframes animations handle the majority of UI motion. Scroll-driven animations (animation-timeline: scroll()) tie animation progress to scroll position natively in CSS, replacing many JavaScript scroll libraries.

Cascade management at scale@layer gives teams explicit control over cascade order in large codebases, eliminating specificity arms races and making third-party style integration predictable.

Reducing JavaScript dependence — many effects that previously required JavaScript are now pure CSS: sticky positioning, smooth scroll, custom scrollbars, has-based parent selection, intrinsic responsive layouts. This improves performance and reduces bundle size.

CSS and component frameworks — in React, Vue, Angular, and Svelte ecosystems, CSS is delivered as CSS Modules, CSS-in-JS (though this approach is declining due to runtime cost), utility classes (Tailwind), or scoped styles. Understanding the cascade still matters in all these contexts.

The key insight for interviews: modern CSS is a capable layout and visual system that can do much more than most developers assume. The skill gap between "knows basic CSS" and "understands the cascade, modern layout, and the full feature set" is large and commercially valuable.

↑ Back to top

Follow-up 1

How does CSS3 support the creation of dynamic web pages?

CSS3 supports the creation of dynamic web pages by providing the ability to apply styles and effects based on user interactions or specific conditions. This can be achieved using CSS3 pseudo-classes and media queries. Pseudo-classes like :hover, :active, and :focus allow developers to apply different styles when an element is hovered over, clicked, or in focus. Media queries enable the adaptation of styles based on the characteristics of the device or viewport, allowing for responsive designs.

Follow-up 2

Can you explain how CSS3 can be integrated with JavaScript?

CSS3 can be integrated with JavaScript to create dynamic and interactive web pages. JavaScript can be used to manipulate CSS properties and classes, allowing for changes in styles based on user actions or events. For example, JavaScript can be used to add or remove CSS classes, toggle styles, or animate elements by changing their CSS properties over time. This integration between CSS3 and JavaScript enables developers to create rich and engaging user experiences.

Follow-up 3

What are some best practices for using CSS3 in web development?

Some best practices for using CSS3 in web development include:

  1. Use external CSS files: Separate the CSS code from HTML by using external CSS files. This promotes code reusability and maintainability.

  2. Use CSS preprocessors: CSS preprocessors like Sass or Less can enhance productivity by providing features like variables, mixins, and nested rules.

  3. Optimize CSS code: Minify and compress CSS files to reduce file size and improve page load times.

  4. Use vendor prefixes: To ensure cross-browser compatibility, use vendor prefixes for CSS properties that are not fully supported by all browsers.

  5. Use CSS frameworks: Utilize CSS frameworks like Bootstrap or Foundation to speed up development and ensure consistency across different projects.

  6. Keep styles modular: Use a modular approach by organizing CSS code into reusable components and classes, making it easier to maintain and update styles.

Follow-up 4

Can you give an example of a project where you used CSS3 to enhance the user experience?

Sure! In a recent project, I used CSS3 to create a smooth scrolling effect for a single-page website. By applying CSS3 transitions and transforms, I was able to animate the scrolling behavior when the user clicked on navigation links. This provided a more visually appealing and interactive experience for the users as they navigated through the different sections of the website. Additionally, I used CSS3 animations to add subtle fade-in effects to certain elements, making the content appear more engaging and dynamic.

5. How does CSS3 support the creation of complex layouts?

CSS provides multiple layout systems for complex page and component structures. In 2026, Flexbox and Grid are the primary tools.

Flexbox — for one-dimensional layouts (a row or a column):

.container {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

Flex items can grow, shrink, and wrap. flex: 1 distributes remaining space evenly. Ideal for navigation bars, card rows, form controls, and any layout where items share a single axis.

CSS Grid — for two-dimensional layouts (rows and columns simultaneously):

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
  gap: 1rem;
}
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }

Grid handles page-level layout and complex component arrangements. Named areas make the layout intent readable. fr units distribute remaining space proportionally.

Subgrid — allows nested elements to participate in a parent grid's track sizing:

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.card { display: grid; grid-row: span 3; grid-template-rows: subgrid; }

This solves the "card with misaligned content rows" problem that previously required JavaScript height matching.

Multi-column layout — for flowing text content across columns like a newspaper:

.content { columns: 3; column-gap: 2rem; column-rule: 1px solid #ddd; }

Intrinsic responsive grids — with auto-fill and minmax(), a grid adapts without explicit breakpoints:

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); }

Container queries complement these layout systems by letting a component respond to its container's size rather than the viewport's, making reusable components truly portable across different layout contexts.

A common interview gotcha: when should you use Grid vs. Flexbox? Flexbox when items flow linearly and their size is determined by content; Grid when you need to control both dimensions or align items across rows. They're complementary — a Grid layout can contain Flex components.

↑ Back to top

Follow-up 1

What is the purpose of the grid layout in CSS3?

The grid layout in CSS3 is a powerful system for creating complex two-dimensional layouts. It allows you to divide a webpage into rows and columns, and then place elements within those rows and columns. With grid layout, you can easily create responsive designs, control the placement of elements, and create complex grid structures. It provides properties like 'grid-template-rows', 'grid-template-columns', 'grid-gap', and 'grid-area' to define the grid structure and control the placement of elements.

Follow-up 2

How does CSS3 support the creation of multi-column layouts?

CSS3 provides the 'column-count' and 'column-width' properties to create multi-column layouts. By setting the 'column-count' property to a specific number, you can divide the content into multiple columns. Alternatively, you can use the 'column-width' property to specify the width of each column, and the browser will automatically calculate the number of columns based on the available space. Additionally, CSS3 provides properties like 'column-gap', 'column-rule', and 'column-span' to control the spacing, borders, and spanning of columns.

Follow-up 3

Can you explain how the flexbox model works in CSS3?

The flexbox model in CSS3 is a layout system that allows flexible and responsive positioning of elements within a container. It consists of a flex container and flex items. The flex container is defined by setting the display property to 'flex' or 'inline-flex'. The flex items are the child elements of the flex container. By using flexbox properties such as 'flex-direction', 'justify-content', 'align-items', and 'flex-grow', you can control the size, order, and alignment of the flex items within the flex container.

Follow-up 4

Can you give an example of a complex layout that you created using CSS3?

Sure! Here's an example of a complex layout created using CSS3:

<div class="container">
  <div class="sidebar"></div>
  <div class="content"></div>
  <div class="sidebar"></div>
</div>
.container {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
}

.sidebar {
  background-color: lightgray;
}

.content {
  background-color: white;
}

In this example, the layout consists of a container with three columns, where the sidebars have a fixed width and the content takes up the remaining space. The grid layout is used to achieve this structure, and the 'fr' unit is used to distribute the available space proportionally.

Live mock interview

Mock interview: CSS vs CSS3

Intermediate ~5 min Your own free AI key

Your voice and your AI key never touch our servers; the key stays in this browser and is sent only to Google. Only your round scores are saved to track progress.