CSS Answers


0:00
0:00

CSS Answers

Basic CSS Answers

#QuestionAnswerExamples
1What is CSS?Cascading Style SheetsA language used to describe the presentation of an HTML document
2What is the purpose of CSS?Controls the look and layout of HTML elementsChanging colors, fonts, sizes, spacing, positioning
3What is a CSS selector?A pattern used to select HTML elements to be styledp, .my-class, #my-id, h1
4What is a CSS property?A characteristic of an HTML element that can be styledcolor, font-size, background-color, margin
5What is a CSS value?The specific setting assigned to a CSS propertyred, 16px, blue, 10px
6How do you link a CSS file to HTML?Using the <link> tag in the <head> section<link rel="stylesheet" href="styles.css">
7What is an inline style?Styles applied directly to an HTML element using the style attribute<p style="color: blue;">This text is blue.</p>
8What is an internal stylesheet?Styles defined within <style> tags in the <head> section<head><style>p { color: red; }</style></head>
9What is an external stylesheet?Styles defined in a separate .css file linked to the HTMLA styles.css file linked via <link>
10What is the color property?Sets the text color of an elementp { color: green; }
11What is the font-size property?Sets the size of the texth1 { font-size: 24px; }
12What is the background-color property?Sets the background color of an elementdiv { background-color: lightgray; }
13What is the margin property?Sets the space outside an element's borderp { margin: 10px; }
14What is the padding property?Sets the space inside an element's border, around the contentbutton { padding: 5px; }
15What is the border property?Sets the border around an elementimg { border: 1px solid black; }

Intermediate CSS Answers

#QuestionAnswerExamples
1What is a class selector?Selects elements based on their class attribute.my-class { font-weight: bold; }
2What is an ID selector?Selects a unique element based on its id attribute#main-header { text-align: center; }
3What is the difference between a class and an ID?Classes can be applied to multiple elements; IDs must be unique on a page.<p class="note">Important</p>, <div id="sidebar-nav">Menu</div>
4What is a descendant selector?Selects elements that are descendants of another elementdiv p { color: blue; } (selects <p> inside a <div>)
5What is an attribute selector?Selects elements based on an attribute name or value[type="text"] { border: 1px solid gray; }
6What is a pseudo-class?Selects elements based on a specific state (e.g., :hover, :active)a:hover { color: red; }, input:focus { border-color: blue; }
7What is a pseudo-element?Selects a specific part of an element (e.g., ::first-letter, ::before)p::first-letter { font-size: 2em; }, h2::before { content: "--- "; }
8Explain the CSS Box Model.Content, Padding, Border, MarginEach element is a box with these four components.
9What is the display property?Specifies how an element is rendered in the document flow (e.g., block, inline, flex)span { display: block; }, li { display: inline; }, nav { display: flex; }
10What is the difference between block and inline elements?Block: Starts on a new line, takes full width; Inline: Doesn't start on a new line, takes necessary width<div> is block, <span> is inline
11What is the position property?Specifies the positioning method for elements (e.g., static, relative, absolute, fixed)div { position: relative; top: 20px; left: 30px; }
12What is position: relative;?Positions an element relative to its normal position in the document flowp { position: relative; top: 10px; }
13What is position: absolute;?Positions an element relative to its nearest positioned ancestor (or initial containing block)span { position: absolute; top: 0; right: 0; }
14What is position: fixed;?Positions an element relative to the viewport (browser window)header { position: fixed; top: 0; width: 100%; }
15What is the z-index property?Specifies the stacking order of overlapping elements.front { position: relative; z-index: 10; }, .back { position: relative; z-index: 5; }

Advanced CSS Answers

#QuestionAnswerExamples
1What is Flexbox?A one-dimensional layout model for arranging items in a row or column.container { display: flex; justify-content: center; align-items: center; }
2What is CSS Grid?A two-dimensional layout model for arranging items in rows and columns.container { display: grid; grid-template-columns: 1fr 2fr 1fr; }
3What is the difference between Flexbox and Grid?Flexbox is primarily 1D layout (row/column); Grid is 2D layout (rows & columns).Use Flexbox for aligning items within a component; Use Grid for overall page layout.
4Explain the concept of CSS specificity.How the browser determines which CSS rule to apply when multiple rules target the same elementInline styles > IDs > Classes/Attributes/Pseudo-classes > Elements.
5What are Media Queries?CSS rules used to apply different styles based on device characteristics (e.g., screen width, height)@media (max-width: 600px) { body { font-size: 14px; } }
6What is Responsive Web Design (RWD)?Designing web pages to look and function well on various devices and screen sizesUsing Media Queries, flexible layouts (Flexbox/Grid), fluid images.
7What is the calc() function?Allows performing calculations within CSS valuesdiv { width: calc(100% - 20px); }
8What are CSS Variables (Custom Properties)?Allows you to store values that can be reused throughout the stylesheet:root { --main-color: blue; } h1 { color: var(--main-color); }
9What is the transition property?Creates smooth animations between styles when an element's state changes (e.g., on hover)button { transition: transform 0.3s ease; } button:hover { transform: scale(1.1); }
10What are CSS Animations?Creates complex sequences of animated effects using keyframes@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .element { animation: fadeIn 1s ease; }
11What is the transform property?Applies 2D or 3D transformations to an element (e.g., translate, rotate, scale)img { transform: rotate(45deg); }, div { transform: scale(1.2); }
12What is the filter property?Applies graphical effects to an element (e.g., blur, brightness, grayscale)img { filter: grayscale(100%); }, div { filter: blur(5px); }
13What is the box-sizing property?Defines how the total width and height of an element are calculated (including padding and border)* { box-sizing: border-box; }
14What is the overflow property?Specifies behavior when content overflows an element's box (e.g., hidden, scroll, auto).container { overflow: auto; }
15What is the concept of CSS Stacking Contexts?Determines how elements overlap based on certain properties (e.g., position value, z-index)Elements with position: relative, absolute, fixed, or sticky and z-index (other than auto) create stacking contexts.

Last updated on July 28, 2025

🔍 Explore More Topics

Discover related content that might interest you

TwoAnswers Logo

Providing innovative solutions and exceptional experiences. Building the future.

© 2025 TwoAnswers.com. All rights reserved.

Made with by the TwoAnswers.com team