Developer Encyclopedia

Learn to Code — CodePrimer

A classroom encyclopedia of HTML5, CSS3, JavaScript, PHP 8, SQL, and Laravel. Search a guide, then follow the learning path from beginner to advanced.

Clear
Popular:

Tag filter: #css Remove

Showing 48 of 291 guides

HTML5 Beginner

Link an external CSS file

How do I attach a stylesheet?

Basics 1 min
HTML5 Beginner

Internal CSS with style tag

How do I put CSS inside the HTML file?

Basics 1 min
CSS3 Beginner

Three Ways to Apply CSS: Inline, Internal, and External

How do I attach CSS to an HTML page?

Modern Layout 7 min
CSS3 Beginner

CSS Selectors: Elements, Classes, Descendants, and Groups

Which CSS selector should I use to target an element?

Selectors 8 min
CSS3 Intermediate

CSS Specificity: Classes, IDs, and !important

Why does my CSS rule lose to another rule?

Selectors 8 min
CSS3 Beginner

The CSS Box Model and border-box Sizing

How do width, padding, border, and margin add up?

Modern Layout 7 min
CSS3 Beginner

CSS Margin, Padding, and Margin Collapse

When does vertical margin collapse, and how do I space elements?

Modern Layout 8 min
CSS3 Beginner

CSS Flexbox: Direction, Alignment, Gap, and Grow

How do I lay out a row of items with Flexbox?

Modern Layout 9 min
CSS3 Beginner

CSS Flex Wrap and Gap for Wrapping Toolbars

How do I let flex items wrap without float hacks?

Modern Layout 7 min
CSS3 Beginner

Center an Element with Flexbox

How do I center a box horizontally and vertically?

Modern Layout 6 min
CSS3 Beginner

CSS Grid Two-Column Layout with a Sidebar

How do I build a content column and a sidebar with Grid?

Modern Layout 8 min
CSS3 Intermediate

CSS Grid: minmax, auto-fit, and grid-template-areas

How do I make a responsive card grid without media queries?

Modern Layout 9 min
CSS3 Intermediate

CSS Positioning: relative, absolute, fixed, sticky, and z-index

How do relative, absolute, fixed, and sticky positioning differ?

Modern Layout 8 min
CSS3 Intermediate

Responsive CSS with Media Queries

How do I change layout at phone, tablet, and desktop widths?

Responsive Design 8 min
CSS3 Advanced

CSS Container Queries with @container

How do I style a component based on its container, not the viewport?

Responsive Design 9 min
CSS3 Intermediate

CSS Custom Properties and var()

How do I share colors and spacing with CSS variables?

Modern Layout 7 min
CSS3 Intermediate

Fluid Typography with clamp()

How do I scale font size between a phone and a desktop without a stack of media queries?

Responsive Design 8 min
CSS3 Intermediate

CSS Transitions for Hover and Focus

How do I animate a color or transform without JavaScript?

Motion 7 min
CSS3 Intermediate

CSS Keyframe Animations

How do I define a reusable @keyframes animation?

Motion 8 min
CSS3 Advanced

Modern CSS Selectors: :has(), :is(), and :where()

How do :has(), :is(), and :where() change selector lists and specificity?

Selectors 9 min
CSS3 Beginner

CSS object-fit and object-position for Replaced Media

How do I crop a photo inside a fixed box without stretching it?

Modern Layout 7 min
CSS3 Beginner

CSS aspect-ratio for Stable Media Frames

How do I reserve a 16:9 box before the image arrives?

Modern Layout 6 min
CSS3 Intermediate

CSS Logical Properties

How do I write margin and padding that follow writing direction?

Modern Layout 7 min
CSS3 Advanced

CSS Cascade Layers with @layer

How do I control stylesheet order without raising specificity?

Selectors 8 min
CSS3 Intermediate

Native CSS Nesting

How do I nest selectors in plain CSS?

Selectors 7 min
CSS3 Intermediate

:focus-visible for Keyboard Focus

How do I style keyboard focus without a ring on every mouse click?

Selectors 7 min
CSS3 Intermediate

CSS Scroll Snap

How do I make a horizontal card row snap into place?

Modern Layout 7 min
CSS3 Advanced

CSS Subgrid

How do I align nested grid items to the parent tracks?

Modern Layout 8 min
CSS3 Beginner

CSS line-clamp for Card Blurbs

How do I cut a paragraph after two lines with an ellipsis?

Modern Layout 6 min
CSS3 Intermediate

CSS text-wrap for Headings

How do I stop a heading from leaving one word on the last line?

Modern Layout 6 min
CSS3 Beginner

CSS accent-color for Form Controls

How do I tint checkboxes and range inputs to match the catalog?

Modern Layout 6 min
CSS3 Intermediate

CSS color-mix for Tinted Surfaces

How do I tint a surface with a brand color without a preprocessor?

Modern Layout 6 min
CSS3 Beginner

CSS overflow for Long Code and Menus

How do I scroll a code sample without stretching the page?

Modern Layout 6 min
CSS3 Intermediate

CSS filter for Image States

How do I grayscale an image until it is hovered?

Modern Layout 6 min
CSS3 Beginner

CSS outline and outline-offset

How do I draw a focus ring that does not shift layout?

Selectors 6 min
CSS3 Beginner

CSS user-select for Copyable and Locked Text

How do I stop a button label from being highlighted when it is double-clicked?

Modern Layout 6 min
CSS3 Intermediate

CSS writing-mode for Vertical Labels

How do I set a vertical spine label without rotating the whole card?

Modern Layout 6 min
CSS3 Intermediate

CSS scrollbar-gutter

How do I stop a list from shifting when a scrollbar appears?

Modern Layout 6 min
CSS3 Beginner

CSS list-style and Counters

How do I number lesson steps without typing the numbers?

Modern Layout 6 min
CSS3 Beginner

CSS cursor for Controls

How do I show a pointer on a clickable card but not on plain text?

Modern Layout 6 min
CSS3 Intermediate

CSS appearance for Native Controls

How do I restyle a select without losing the control?

Modern Layout 6 min
CSS3 Intermediate

CSS hyphens for Narrow Columns

How do I break long words in a narrow lesson column?

Modern Layout 6 min
CSS3 Advanced

CSS isolation for Stacking Contexts

How do I stop a card shadow from mixing with a popup z-index?

Modern Layout 6 min
CSS3 Beginner

display block inline flex

How does display change layout?

Layout 1 min
CSS3 Beginner

Hover and focus-visible

How do I style hover and keyboard focus?

Selectors 1 min
CSS3 Beginner

Truncate long text with ellipsis

How do I cut overflow text with …?

Components 1 min
CSS3 Beginner

Simple CSS reset start

How do I normalize browser defaults a bit?

Basics 1 min
CSS3 Beginner

Space-between header layout

How do I put logo left and links right?

Layout 1 min

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…