TGViewer
Web Development Web Development @webdevcoursefree ยท 79.6K subscribers
Post #3753 2.79K
๐Ÿš€ Web Development Interview Questions with Answers โ€” Part 2: CSS

๐Ÿง  21. What is CSS?
CSS stands for Cascading Style Sheets.
It is used to style and design HTML elements.

CSS helps to:
โ€ข Add colors
โ€ข Set fonts
โ€ข Create layouts
โ€ข Add animations
โ€ข Make websites responsive

Example:

h1 {
color: blue;
font-size: 40px;
}


๐Ÿง  22. Difference Between Inline, Internal, and External CSS
Type : Description
Inline CSS : Written inside HTML element
Internal CSS : Written inside <style> tag
External CSS : Written in separate .css file

Inline CSS:

<h1 style="color:red;">Hello</h1>


Internal CSS:

<style>
h1 {
color: blue;
}
</style>


External CSS:

<link rel="stylesheet" href="style.css">


๐Ÿง  23. What is Specificity in CSS?
Specificity determines which CSS rule is applied when multiple rules target the same element.

Priority Order:
1. Inline CSS
2. ID Selector
3. Class Selector
4. Element Selector

Example:

#title {
color: red;
}

.heading {
color: blue;
}


ID selector has higher priority.

๐Ÿง  24. Explain CSS Box Model
Every HTML element is treated as a box.

The box model contains:
โ€ข Content
โ€ข Padding
โ€ข Border
โ€ข Margin

Structure:

Margin
โ”” Border
โ”” Padding
โ”” Content


Example:

div {
padding: 20px;
border: 2px solid black;
margin: 10px;
}


๐Ÿง  25. Difference Between Margin and Padding
Margin : Space outside border
Creates gap between elements

Padding : Space inside border
Creates inner spacing

Example:

div {
margin: 20px;
padding: 20px;
}


๐Ÿง  26. What is Flexbox?
Flexbox is a one-dimensional layout system used for alignment and spacing.

Benefits:
โœ… Easy alignment
โœ… Responsive layouts
โœ… Flexible spacing

Example:

.container {
display: flex;
justify-content: center;
align-items: center;
}


๐Ÿง  27. What is CSS Grid?
CSS Grid is a two-dimensional layout system.

It handles:
โ€ข Rows
โ€ข Columns

Example:

.container {
display: grid;
grid-template-columns: 1fr 1fr;
}


๐Ÿง  28. Difference Between Relative, Absolute, Fixed, and Sticky Positioning
Position : Description
relative : Positioned relative to itself
absolute : Positioned relative to parent
fixed : Fixed on screen
sticky : Sticks during scrolling

Example:

div {
position: absolute;
top: 20px;
}


๐Ÿง  29. What is z-index?
z-index controls stack order of elements.

Higher z-index appears on top.

Example:

.box {
z-index: 10;
}


๐Ÿง  30. Difference Between em, rem, %, px, vh, and vw
Unit : Meaning
px : Fixed pixels
% : Relative percentage
em : Relative to parent
rem : Relative to root
vh : Viewport height
vw : Viewport width

Example:

h1 {
font-size: 2rem;
}


๐Ÿง  31. What are Pseudo-Classes?
Pseudo-classes define special states of elements.

Examples:

a:hover {
color: red;
}


Common Pseudo-Classes:
โ€ข :hover
โ€ข :focus
โ€ข :first-child
โ€ข :last-child

๐Ÿง  32. What are Pseudo-Elements?
Pseudo-elements style specific parts of elements.

Example:

p::first-letter {
font-size: 40px;
}


Common Pseudo-Elements:
โ€ข ::before
โ€ข ::after
โ€ข ::first-letter

๐Ÿง  33. Difference Between visibility:hidden and display:none
visibility:hidden : Element hidden but space remains
display:none : Element removed completely

Example:

.box {
display: none;
}


๐Ÿง  34. What is Media Query?
Media queries make websites responsive.

Example:

@media (max-width: 768px) {
body {
background: lightblue;
}
}


๐Ÿง  35. Explain Responsive Design
Responsive design ensures websites work on:
โ€ข Mobile
โ€ข Tablet
โ€ข Desktop

Techniques:
โœ… Media Queries
โœ… Flexible layouts
โœ… Responsive images 

๐Ÿง  36. What is Mobile-First Design? 
Mobile-first design means designing for smaller screens first and then scaling upward. 

Benefits: 
โœ… Better performance 
โœ… Better UX on mobile devices 
  • โค 4
More from @webdevcoursefree
  1. Oct 13, 2026๐—ง๐—ข๐—ฃ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐—ง๐—ข ๐—•๐—ข๐—ข๐—ฆ๐—ง ๐—ฌ๐—ข๐—จ๐—ฅ ๐—ฆ๐—ž๐—œ๐—Ÿ๐—Ÿ๐—ฆ ๐—œ๐—ก ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! Explorโ€ฆ
  2. Oct 12, 2026For example: Go to Profile โ†’ <a> Submit Form โ†’ <button> Open Article โ†’ <a> Delete Accountโ€ฆ
  3. Oct 12, 2026๐ŸŒ Web Development Roadmap โ€” Part 16 HTML Links โ€” Tag Links are one of the most importantโ€ฆ
  4. Oct 12, 2026๐Ÿš€ ๐—ช๐—ต๐—ถ๐—ฐ๐—ต ๐—ง๐—ฒ๐—ฐ๐—ต ๐—ฆ๐—ธ๐—ถ๐—น๐—น ๐—ช๐—ถ๐—น๐—น ๐—ฌ๐—ผ๐˜‚ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ? Want to builโ€ฆ
  5. Oct 9, 2026Post #4079
  6. Oct 9, 2026Post #4078
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’