1. Which selector targets all paragraph elements with class 'intro'?
The selector p.intro means: select all <p> elements that have the class 'intro'. This is basic CSS selector syntax — very common in interviews.
p.intro { color: blue; }Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
CSS · Question Set
CSS Fundamentals interview questions for placements and exams.
Questions
13
Included in this set
Subject
CSS
Explore more sets
Difficulty
Mixed
Level of this set
Go through each question and its explanation. Use this set as a focused practice pack for CSS.
The selector p.intro means: select all <p> elements that have the class 'intro'. This is basic CSS selector syntax — very common in interviews.
p.intro { color: blue; }For complete preparation, combine this set with full subject-wise practice for CSS. You can also explore other subjects and sets from the links below.
The rgb(255,0,0) value represents red in RGB color format. CSS supports named colors, HEX, RGB, RGBA, and HSL. This is often asked in web styling interviews.
h1 { color: rgb(255, 0, 0); }The 'em' unit scales relative to the parent’s font size. If parent font size is 16px, then 1.5em equals 24px. Understanding units helps in responsive design and scaling text properly.
p { font-size: 1.5em; }Check for typos, rule order, specificity, and file linking. Use browser dev tools to inspect applied styles. Showing a structured approach like this in interviews demonstrates practical experience.
/* Example: Using DevTools to check active CSS rules */
Selectors target elements for styling. They help apply consistent design to multiple elements without duplication. Good selector use means cleaner, maintainable code — a skill companies value in interviews.
button.primary { background-color: green; }CSS stands for Cascading Style Sheets. It is used to style HTML elements — controlling layout, colors, and fonts. In interviews, explaining that CSS separates design from content shows understanding of modern web practices.
body { background-color: lightblue; }The correct syntax is p { color: red; }. The property 'color' changes the text color. This tests basic CSS property knowledge — often asked in coding rounds.
p { color: red; }We use the <link> tag inside the head section to attach an external CSS file. Example: <link rel='stylesheet' href='style.css'>. This question checks if you understand how external styling works in real projects.
<head> <link rel="stylesheet" href="style.css"> </head>
Inline CSS applies directly to elements. Internal CSS is written in the head tag using <style>. External CSS is stored in a separate file linked with <link>. External is best for scalability and reusability — a frequent interview topic.
<link rel="stylesheet" href="style.css">
Cascading means the order of style application. When multiple rules affect the same element, the one with higher specificity or later in the code wins. Explaining this clearly impresses interviewers — it shows real debugging skill.
p { color: blue; }
p.special { color: red; }px is absolute, em and rem are relative. em depends on parent font-size, rem depends on root font-size. In interviews, emphasize that rem gives consistent scaling for responsive designs.
h1 { font-size: 2rem; }Inline CSS has the highest priority because it is applied directly to the element. Then internal, then external. Understanding priority helps in debugging style conflicts in real projects.
<p style="color: red;">This text is red</p>
CSS comments are written between /* and */. Comments are ignored by the browser and used to describe code sections — useful for teamwork and interviews about best practices.
/* This is a CSS comment */
p { color: blue; }