You design a web page with HTML and CSS by separating structure from presentation: HTML carries the meaning and order of your content, CSS controls how that content looks and reflows. Write the HTML first with sensible elements and a logical reading order, then layer visual design on top with a small set of CSS layout, spacing, type, and color rules. The one condition that makes everything else easier is to plan the skeleton and its breakpoints before you touch colors. This guide walks through the full process, from a blank file to a page you can check, adjust, and even hand to someone else.

Set Up the Smallest Working Environment

You need very little to start: a text editor and a browser. Any modern editor works, and the browser's developer tools do the rest. Create a project folder with a single HTML file and, once you outgrow inline styles, a separate stylesheet.

A predictable starter structure keeps things tidy:

index.html at the top of the folder. A css/ subfolder holding styles.css. An images/ or assets/ folder for pictures, icons, and fonts. Consistent, lowercase file names with hyphens instead of spaces.

Link the stylesheet in the document head, and add the viewport meta tag so mobile browsers don't fake a desktop width. That single line is the reason your later responsive work behaves sensibly on phones:

You don't need a framework or build tool to follow this process. Add them later once you understand what they automate, or you'll be debugging magic instead of markup.

Write the HTML First: Meaning, Order, and Skeleton

Open index.html and type the document skeleton: doctype, html element with a language attribute, head containing the title and metadata, and a body. Then fill the body with content in the order a reader needs it, not the order it looks good on screen.

Start with landmark regions. A header holds the site name and primary navigation. A main element wraps the page's unique content. A footer closes it out. Inside main, sections group related content, and each section usually gets a heading. Use article only for self-contained content that would make sense syndicated elsewhere (a post, a card of information), and aside for tangential material.

A usable outline for a simple page looks like this, deliberately unstyled:

The markup uses real semantics: a heading, paragraphs, a list in the navigation, and named landmarks. Semantic HTML matters because screen readers navigate by landmarks and headings, search engines read structure, and browsers give you sensible defaults for free.

One practical habit pays off: write all your text content before worrying about layout. Placeholder-free copy saves wrestling with fake text.

Add CSS in Layers: Reset, Rules, Then Polish

Link the stylesheet in the head after the metadata:

Then build your CSS in three passes.

First, a light reset. Browsers apply their own default margins and heading sizes. You don't need a giant reset library; a few rules tame the quirks. Set box-sizing to border-box on everything, remove the body margin, and make images behave:

border-box makes width include padding and borders, which is almost always what people mean when they say "this box is 100% wide."

Second, your own base rules: a readable font stack, comfortable line height, a sensible body color, and link styles. Large blocks of serif versus sans-serif reading text are a taste and accessibility question; whatever you pick, keep body text at a comfortable size and enough contrast against the background.

Third, layout and components. The strongest modern approach is flexbox for one-dimensional rows and columns, and CSS grid for two-dimensional page structure. Both have been supported reliably in current browsers for years, so there's little reason to reach for float hacks or absolute positioning for ordinary layout.

Build a Page Layout You Can Reason About

A dependable page layout is a sticky header and a main content area that caps its width. A centered content column, sometimes called a container, is the core of most page designs:

margin-inline: auto centers the block; max-width keeps lines from stretching into unreadable territory on wide monitors.

For a header with a brand on one side and nav on the other, flexbox with space-between is the direct answer:

Sticky positioning needs a top value, which is a common trip-up: sticky with no top just sits there.

For cards in a grid, auto-fit plus a minimum width gives you a responsive layout without writing a single media query:

The page below pulls the header, container, and cards together. It caps in—did you notice whether the max-width setting is applied to the container or the card grid? It won't matter as long as one of them does. The point of the rule is to keep the layout predictable, not elegant for its own sake.

Space, Type, and Color: Choose Systems, Not One-Off Values

Beginners often pile up near-identical values: 13px here, 14px there, 17px margins. Design gets easier if you define a few tokens and reuse them. CSS custom properties make this clean:

Use those tokens for margins, padding, font sizes, and colors rather than scattering new numbers. Consistent spacing is most of what makes a page look designed.

Type hierarchy does more work than fonts do. In general, set body text at a comfortable size, use a line height around 1.5–1.7 for paragraphs, and make headings clearly larger. clamp() lets headings scale between a minimum and maximum as the viewport changes, which is a lightweight substitution for several media queries.

Color is the highest-stakes choice because it affects readability and accessibility. Contrast is the rule to respect: normal body text should ideally clear a 4.5:1 contrast ratio against its background, and large or bold display text can sit lower, around 3:1. These ratios come from WCAG's contrast requirements, and the exact thresholds depend on text size and weight. Don't rely on lightness intuition. A pale gray paragraph text on white looks stylish and reads badly. Check contrast with any online contrast checker, and check again when you change colors under dark-mode rules.

Make It Responsive Without a Breakpoint Avalanche

Responsive design isn't "add a bunch of breakpoints." Modern CSS gives you intrinsic behaviors first: flexible grid columns via auto-fit, flexible images via max-width, and scaling type with clamp(). You add explicit media queries only when those aren't enough.

A reliable responsive ladder:

1: Build the page for a narrow screen first: single column, no side padding beyond your container padding, oversized tap targets. 2: Let the grid handle card columns as space grows, as the auto-fit recipe above does. 3: Add a small number of breakpoints, say around commonly needed widths, for layout changes that fl%exibility can't express—like collapsing navigation into a menu button or moving a sidebar beside the content. 4: Test by resizing the browser window slowly, not by jumping between tablet and phone presets. The in-between sizes are where layouts break.

A single media query often covers the biggest shift:

Mobile-first means "min-width" queries, with base styles assuming the tight screen. It's not a moral rule, but it tends to produce fewer overrides.

Check It Visually and with Developer Tools

Verification is where design becomes reliable. Open the page in a browser, then use developer tools—accessible in Chrome, Firefox, Safari, and Edge via standard shortcuts or menus—for a few specific checks:

The Elements panel lets you see the box model: computed margins, borders, and padding. If something is mysteriously positioned, check whether box-sizing is applied. The Layout panel shows grid and flex overlays. For grid, you can toggle line numbers and see exactly where items land. The Styles panel shows which rules win. The "computed" tab shows what the browser actually resolved, which is decisive when two rules conflict. The Responsive Design Mode (some browsers call it Device Toolbar or Responsive Design View) lets you resize without moving windows and test touch-sized targets.

Two keyboard-only spot checks catch a surprising amount: tab through links and buttons to confirm that focus is visible, and zoom the browser text to see if the layout holds. If a fixed-height box clips text when users enlarge the font, that's a real defect, not a stylistic preference.

You can also validate your HTML through the W3C Markup Validation Service and your CSS through the W3C CSS Validator. Neither guarantees design quality, but they catch structural mistakes—unclosed tags, stray syntax—before they become debugging mysteries.

A Worked Example: From Blank File to Finished Section

Here's an end-to-end pass over one section to see how the layers combine. Suppose the page needs a featured "plants" section with a heading, a paragraph, and three cards.

Start with honest markup:

Then style it with tokens and one grid rule:

Expected result: on a phone the three cards stack in one column; as the window widens, they sit two and then three across; the container caps the section's width. To check success, drag the window width slowly and watch for cards that jump or text that clips. Also inspect a card's computed styles to confirm your spacing tokens match the values you intended. This is where small inconsistencies—a margin you meant to use elsewhere—surface.

Organize CSS So the Page Scales to a Second Page

As soon as you build a second page, copy-paste CSS becomes the enemy. A simple layering convention avoids that. Put custom properties at the top, then a lightweight reset, then base element styles, then layout utilities such as the container, then components (cards, buttons, navigation), then media queries. A comment header for each layer keeps it findable.

Keep specificity low. Prefer classes over deep descendant selectors; flat classes are easy to override and reason about. Avoid !important unless you're fighting an external library, because it escalates quickly. A single well-named class beats three tag-and-class combinations.

Name classes by role rather than appearance: "card," "nav-list," "alert," not "big-red-box." Appearance names age badly when you restyle.

The result, checked simply: pick a color or spacing token, change its value in the root, and confirm that every use updates. If some elements don't, you've missed a hardcoded value that should be a token.

Common Failures and How to Debug Them

Most page bugs fall into a handful of categories. Each has a quick, reversible first check.

If the layout stretches wider than the screen on a phone, suspect a fixed width, an unsized image, or horizontal padding added to 100%-wide elements. First fix: inspect the offending element in developer tools and look for width values that don't have a maximum, or apply max-width: 100% to images and width: 100% to the container.

If margins collapse—two vertical margins becoming one gap instead of two—remember that adjoining block margins collapse under normal flow. First fix: replace one of the margins with padding, or separate elements with a flex or grid container, which changes the rules.

If a rule won't apply, check the Styles panel. Often another selector with equal or higher specificity, or a more recently loaded rule, overrides it. First fix: reduce the conflicting selector's reach or reorder the stylesheet so the intended rule loads last among equals.

If a sticky header fails, confirm position: sticky has a top offset and that no ancestor has overflow: hidden or an inexplicable transform. Overflow on a parent can silently kill sticky.

Stop conditions: if the browser reports an unresolved error you can't trace, or if the page renders differently across the major current browsers in a way you can't attribute to known feature support, pause and reduce the page to the smallest failing section to isolate the cause. And if posture, SEO indexing, or third-party script integration is part of the goal, those rely on practices outside plain HTML and CSS—treat them as separate discussions rather than guesses folded into the styling.

A quick stacking-context tip: if a tooltip or menu disappears behind another element, z-index alone may not fix it. An ancestor with a transform or specific position values can create a new stacking context, which changes what z-index applies within. Look at the ancestor chain first.

When the Principles End and Current Details Begin

Everything in this guide rests on stable, long-supported behavior: HTML semantics, CSS box model, flexbox, grid, custom properties, and WCAG's contrast approach. Design principles themselves—hierarchy, spacing consistency, readable line lengths—don't change with browser releases.

But some details are version- and platform-dependent: exact developer-tools panel names and locations vary across Chrome, Edge, Firefox, and Safari and can change between releases; specific new CSS features and their browser support arrive on a rolling schedule; font and host availability vary by provider. For those, check the current browser documentation and the compatibility information for the feature you plan to use rather than relying on a remembered version. If you work inside an organization's hosting or content platform, its template constraints and review process also shape what you can do, so check those before designing too far ahead.

The durable method is to build semantics first, style with tokens and one-dimensional layouts, verify with developer tools and slow window resizing, and keep checking at real device sizes and real text sizes. That approach usually survives redesigns and new browsers. Start with a single unstyled page and one honest hour of structuring before you open the color picker—the design tends to fall into place more easily when the content is already in the right order.