Avoid these 5 beginner CSS mistakes

Kevin Powell

Kevin Powell

21 min, 38 sec

The video discusses common CSS mistakes made by beginners, with demonstrations and solutions.

Summary

  • The presenter reflects on his own CSS mistakes and aims to address common errors made by beginners.
  • Emphasizes that making mistakes is normal and encourages learning from them.
  • Demonstrates issues such as collapsing margins, misunderstanding positioning, and specificity problems with IDs.
  • Advises against the use of named colors and over-reliance on a single layout tool like Flexbox or Grid.
  • Promotes his course, CSS Demystified, for those wanting to deepen their CSS knowledge.

Chapter 1

Introduction to Common CSS Mistakes

0:00 - 45 sec

The presenter introduces the topic of common CSS mistakes made by beginners.

The presenter introduces the topic of common CSS mistakes made by beginners.

  • The presenter has been teaching CSS for 10 years and shares his insights on common mistakes.
  • A video has been created to discuss the presenter's own CSS errors and fixes.
  • It is emphasized that making mistakes is part of the learning process and should not be discouraging.

Chapter 2

Collapsing Margins

1:05 - 2 min, 45 sec

A demonstration of collapsing margins using multiple divs and H1 tags.

A demonstration of collapsing margins using multiple divs and H1 tags.

  • Margins of adjacent divs collapse into each other, not creating the expected spacing.
  • Adding a small padding can prevent margins from collapsing.
  • The presenter references a more detailed video on collapsing margins for further explanation.

Chapter 3

Background Color and Padding

4:02 - 1 min, 59 sec

Exploring the use of padding for background color and spacing issues.

Exploring the use of padding for background color and spacing issues.

  • A common issue is adding margin to an element and it moves the parent instead of the child due to collapsing margins.
  • Using padding on the parent element instead of margin on the child can resolve this issue.
  • The importance of understanding the cause of these issues is stressed.

Chapter 4

Positioning Elements

6:21 - 1 min, 28 sec

Avoiding layouts using absolute positioning for multiple elements.

Avoiding layouts using absolute positioning for multiple elements.

  • The presenter advises against using absolute positioning for layouts as it may lead to overlapping and difficult to manage designs.
  • Flexbox or Grid should be used for layouts instead of absolute positioning.
  • The video includes links to further resources on making responsive designs with absolute positioning.

Chapter 5

Understanding Containing Blocks

8:21 - 3 min, 11 sec

An example is given to explain the concept of containing blocks in CSS positioning.

An example is given to explain the concept of containing blocks in CSS positioning.

  • Positioning an element using absolute coordinates can cause issues when screen size changes.
  • Setting a parent element to position relative can define a new containing block for absolutely positioned children.
  • The presenter uses a testimonial quote design to illustrate how understanding containing blocks helps position elements correctly.

Chapter 6

Choosing Between Flexbox and Grid

12:32 - 3 min, 19 sec

The presenter discusses when to use Flexbox vs Grid and highlights their respective strengths.

The presenter discusses when to use Flexbox vs Grid and highlights their respective strengths.

  • Flexbox is better suited for layouts where the children control the size and Grid is better when the parent controls the size.
  • Flexbox and Grid each have strengths that should be utilized for specific layout needs.
  • Beginners should learn the basics of both Flexbox and Grid for versatility in CSS layouts.

Chapter 7

Avoiding Named Colors

15:52 - 2 min, 6 sec

The presenter advises against using named colors for precise color control.

The presenter advises against using named colors for precise color control.

  • Named colors often do not match expectations and can be misleading.
  • For more accurate color choices, use hex codes, RGB, HSL, or color pickers.
  • Named colors are suitable for quick demos or visualizations but not for final designs.

Chapter 8

Avoiding IDs as Selectors

18:19 - 3 min, 0 sec

The presenter warns about the pitfalls of using IDs as selectors due to their high specificity.

The presenter warns about the pitfalls of using IDs as selectors due to their high specificity.

  • IDs can be difficult to override because of their high specificity in the CSS cascade.
  • Using classes instead of IDs can avoid future styling conflicts.
  • IDs are useful for JavaScript selection and anchor links but should be used with caution for styling.

More Kevin Powell summaries

Incredible scroll-based animations with CSS-only

Incredible scroll-based animations with CSS-only

Kevin Powell

Kevin Powell

A guide to creating scroll-linked animations using only CSS.

A practical guide to responsive web design

A practical guide to responsive web design

Kevin Powell

Kevin Powell

A detailed exploration of strategies for writing effective and responsive CSS for modern web design.

The background values no one knows about

The background values no one knows about

Kevin Powell

Kevin Powell

The video discusses two lesser-known CSS background repeat properties: space and round, and demonstrates their use with a star rating example.