CSS
Cascading Style Sheets
The language for styling web pages. Defines the layout, colors, and fonts of HTML elements. Flexbox and Grid are central.
Cascading Style Sheets
The language for styling web pages. Defines the layout, colors, and fonts of HTML elements. Flexbox and Grid are central.
CSS (Cascading Style Sheets) is a web page styling language standardized by the W3C in 1996. While HTML defines the structure of content, CSS applies visual presentation (colors, layout, fonts, animations, etc.) to that structure. 'Cascading' refers to the way in which styles are applied according to priority when multiple style rules conflict.
The core of modern CSS is the Flexbox and Grid layout systems. Flexbox is optimized for one-dimensional layouts (rows or columns), while Grid is optimized for two-dimensional layouts (rows and columns at the same time). As of 2024, more than 98% of global browsers fully support both systems.
CSS follows a three-level selector priority (Specificity): inline styles (1000 points) > ID selectors (100 points) > class selectors (10 points) > element selectors (1 point). !important ignores this rule and is applied with the highest priority, but it makes maintenance difficult, so its use is discouraged.
Recently, powerful features such as CSS Variables (Custom Properties), Container Queries, and the :has() selector have been added to CSS. In particular, alongside the CSS-in-JS debate, various styling methodologies such as Tailwind CSS, CSS Modules, and styled-components coexist and continue to evolve.
/* CSS Variablesμ Flexbox/Grid λ μ΄μμ */
:root {
--primary-color: #a855f7;
--spacing-md: 1rem;
--radius: 12px;
}
/* Flexbox: λ€λΉκ²μ΄μ
λ° */
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: var(--spacing-md);
gap: 1rem;
}
/* Grid: μΉ΄λ λ μ΄μμ */
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: var(--spacing-md);
}
/* λ°μν λμμΈ */
@media (max-width: 768px) {
.navbar {
flex-direction: column;
}
.card-grid {
grid-template-columns: 1fr;
}
}
/* λͺ¨λ CSS: Container Query */
@container (min-width: 400px) {
.card {
padding: 2rem;
}
}
/* μ λλ©μ΄μ
*/
.button {
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(168, 85, 247, 0.3);
}
"Looking at the Figma file the design team sent, the spacing for each component is consistently based on 8px units. If we define --spacing-unit: 8px with CSS Variables and use multiples of it, communication between development and design should become smoother."
"Interviewer: What is the difference between Flexbox and Grid?
Candidate: Flexbox is a one-dimensional layout that arranges items in one direction (row or column), while Grid is a two-dimensional layout that controls rows and columns at the same time. Flexbox is suitable for linear arrangements such as navigation bars, and Grid is suitable for grid-style arrangements such as dashboards or galleries."
"!important is used three times in this component, so it seems there is a specificity conflict. When I looked for the cause, the parent component is using inline styles. If we change the inline styles to classes, it should be resolved even without !important."
Take a mock interview on this topic β WIA SOOM AI Interview Β· Start for free