You build a web page by writing three files: an HTML file for structure and content, a CSS file for appearance, and a JavaScript file for interaction—then opening the HTML file in a browser or publishing the folder to a host. The only real prerequisite is a plain text editor and a browser; you can start with nothing else installed. Everything below assumes you're building a static page rather than a database-backed application, because that's the version of this task you can finish in an afternoon and then extend as far as you want.

A static page is a folder of files. The browser reads the HTML, follows its links to the stylesheet and script, and renders the result on the reader's machine. Once that mental model is in place, "coding a web page" stops being mysterious: you're authoring text files with specific names and syntax, and the browser is a very literal interpreter of them.

Set Up Before You Write Any Markup

Prerequisites, in order: a text editor, a browser, and a project folder. Any editor works, from Notepad to VS Code to a terminal-based editor; the only thing that matters is that it saves plain text with no rich formatting. Create a folder somewhere sensible, such as my-site, and keep every file for this project inside it. Browsers restrict how pages load local files in some cases, so working from one folder keeps relative paths simple.

One naming rule: use lowercase letters, digits, and hyphens in filenames and avoid spaces. about-us.html is safe; About Us (final).html will cause you grief when URLs start getting encoded as About%20Us%20(final).html. Likewise, name your homepage index.html, because web servers and most static hosts serve that file automatically when someone visits your domain.

No installs are required, but two optional tools pay off quickly. A code editor with syntax highlighting catches mismatched brackets and unclosed quotes before the browser does. Your browser's developer tools—open with F12 or the browser menu—show the page's live HTML structure and any errors in the console, and they're the fastest way to answer "why isn't this styling applying?"

Success check: you have an empty folder and know how to open a file from the system file manager in your browser. If you don't yet, create the folder and skip ahead once you have.

Write the HTML Skeleton That Every Page Needs

Start with the document shell. HTML documents follow a fixed opening structure, and getting it right once means you can copy it for every page afterward. Create index.html in your editor and type or paste this:

Save it, then open the file in your browser (double-click it, or drag it onto a browser window). You should see a large heading and a line of text.

Here's what each piece does. tells the browser to use standards mode rather than a legacy compatibility mode. lang="en" declares the page's primary language, which affects screen readers and translation prompts. The charset declaration makes the browser read the file as UTF-8, so accented letters and non-Latin scripts display correctly instead of turning into gibberish. The viewport line matters for phones: without it, mobile browsers render at a wide desktop width and shrink everything. The sets the text shown in the browser tab. The element points to the stylesheet you'll create next—if styles.css doesn't exist yet, nothing breaks; the browser just logs a failed request.

The body is where content lives. is the top-level heading and should appear once per page in most cases. is a paragraph. Text inside them is ordinary prose—no special syntax needed for spacing.

Success check: the page displays the heading and paragraph with a browser tab reading "My First Page." If you see raw markup on screen instead, your file was probably saved with an .html.txt extension; rename it so it ends in .html.

Learn Just Enough HTML Structure to Build Real Content

With the shell working, HTML is a catalog of elements that describe what content is, not how it looks. The ones that carry most pages:

Headings through for section hierarchy.

for paragraphs, for importance, for emphasis.

and with for unordered and ordered lists; with and for term–description pairs. for links, ... for images (the alt text is required for accessibility and is what shows if the image fails). , , , , , , and for page regions. These are semantic containers—they don't render specially, but they make your structure legible to screen readers and search engines and make your CSS selectors more meaningful. and for images with captions; and for quotations. A worked example of a content section: Two structural rules matter more than the rest. First, nest correctly: every opened tag needs a matching close, in order, like parentheses. Second, keep the outline sensible—one followed by sections, not a heading jumped over for visual size. If you need text to look smaller, that's a job for CSS, not for picking an inappropriate heading level. A common failure case is deprecated formatting elements like , , , and . They still render, but they mix appearance into structure and teach the wrong mental model. Use CSS instead; you'll learn the equivalent properties below. Make It Look Right With a CSS Stylesheet Now create styles.css in the same folder. The rules below give you a page that reads comfortably on both phones and desktops: Save it and refresh the browser. The text should now be in a system font, centered in a column no wider than about 40 character-widths' worth of rems, with comfortable line spacing and a blue link color. That gradient from black text on white to a readable page illustrates how CSS works: you select elements with selectors, then declare properties for them. Simple type selectors (h1, a) are enough to start. Class selectors ( matched by .intro) let you target specific pieces, and ID selectors (#site-title) are for unique elements. Prefer classes; IDs have a habit of multiplying and are awkward to reuse. A few CSS facts save beginners hours of confusion. The cascade means later declarations override earlier ones of equal specificity, and more specific selectors beat more general ones. Inheritance means properties like font-family flow down to children while properties like margin don't. And the box model—content, padding, border, margin—dictates that widths add up in ways people don't expect until they see it. Setting box-sizing: border-box globally (in *) makes an element's declared width include its padding and border, which nearly always matches what you intended when eyeballing layouts. For layout itself, start with a simpler tool than you might expect: a single-column layout, as above, needs almost nothing. When you need items side by side, Flexbox is the first thing to reach for—display: flex on the parent and gap for spacing handles rows of cards, nav bars, and centered buttons. For two-dimensional arrangements, CSS Grid with display: grid and explicit columns does the job. Media queries let you change rules at certain viewport widths (@media (min-width: 50rem) { ... }), which is how the same page adapts from phone to desktop. Success check: save the CSS, refresh, and confirm the styles apply. If they don't, open developer tools, click the element, and look at the styles panel to see which rules are being overridden or whether the stylesheet failed to load—the Network tab shows a 404 if the path is wrong. Add Behavior With a Small Amount of JavaScript Interaction is where pages start feeling like software. Create script.js and link it at the end of the body in index.html, before the closing tag: Placing the script at the end means the HTML above it already exists when the script runs, avoiding a common bug where a script tries to find an element that hasn't been parsed yet. A minimal working example—a button that toggles a message: And the matching HTML: That covers most of what "interactive" means for a first page: finding elements, listening for events, and changing content or attributes in response. The hidden attribute is a built-in way to hide something, and toggling it is more accessible by default than manipulating CSS display because screen readers respect it consistently. Where beginners go wrong is trying to do too much in JavaScript before HTML and CSS are solid. A page that displays content and styling correctly without JavaScript still works if the script fails; a page whose entire content is generated by an unverified script shows a blank screen when something breaks. Progressive enhancement—build the HTML version first, add behavior on top—is the professional habit that makes that failure mode rare. Check success by clicking the button: the message should appear and disappear, and the button label should change. If clicking does nothing, open the console; an error like "Cannot read properties of null" means your selector matched nothing, usually because an ID is misspelled. Organize Files and Preview the Page Properly Before writing more pages, establish a small folder convention so paths stay predictable: Reference the image from any page as images/hero.jpg, and pages in the same folder link to each other with plain filenames like href="about.html". A site under ten pages needs no build step or framework; just keep the names and folders tidy. Previewing is as simple as refreshing the browser after each save, but two habits improve the process. First, keep developer tools docked and open the console—uncaught errors appear there and nowhere else. Second, test at a narrow window width by resizing the browser, or use the device toolbar in developer tools to simulate a phone. It's much cheaper to catch a layout that breaks at 375 pixels wide now than after you've built five more pages. For local development, some people run a tiny local server (Python's python -m http.server, for instance) rather than opening files directly. It's rarely necessary for plain pages but helps once you're fetching data files or using modules, both of which browsers restrict on file:// URLs for security reasons. Success check: clicking a link to about.html loads that page, and the image appears. If the image is broken, right-click it and inspect the URL the browser attempted—the path is almost always the problem. Validate, Check Accessibility, and Fix the Usual Failures A page that looks right can still be structurally wrong in ways that hurt search engines, screen readers, and future maintenance. Three cheap checks catch most issues: 1: Validate the HTML. The W3C's markup validator will list unclosed tags and invalid nesting. Not every warning demands action, but errors are worth fixing. 2: Navigate with the keyboard only. Tab through the page and confirm every link and button is reachable with a visible focus outline. This one test surfaces the majority of practical accessibility problems. 3: Check contrast. Body text should be dark enough against its background that it's readable in bright light. If you're picking a palette, contrast-checking tools quantify this rather than leaving it to taste. The usual failures, and their causes: text runs together because a paragraph was written without tags and the browser collapsed the whitespace; the layout overflows to the right on phones because a fixed pixel width was set on a wide element; a click handler "never fires" because the script loaded before the element existed, or because an ID in the selector was misspelled; styles "don't apply" because the path is wrong or a later rule with higher specificity is winning. Developer tools answer each of these in under a minute. A specific stop condition: if you're embedding third-party content, handling user accounts, or accepting payments, stop and use documented platform integrations rather than hand-rolling them. Security-sensitive features—authentication, payment forms, storing personal data—need expertise and carefully maintained libraries, not a first project's worth of JavaScript. Publish the Folder When the Local Version Is Solid Local files only exist on your computer. Publishing means copying the folder to a host that serves it over HTTPS to anyone with the address. Several categories of hosting exist for static pages, from free tiers of general web hosts to static-site platforms that connect to a code repository and deploy on each push. The common requirement across all of them is the same: the host serves index.html at the site root, and the folder structure is preserved. The general steps are: create an account with a host, upload the project folder (via the host's file manager, drag-and-drop interface, or connecting a repository), confirm that index.html sits at the root of the upload—not inside an extra subfolder, which is the single most common publishing mistake—and then visit the address the host provides. If the page is blank or the styles are missing, compare the deployed file list to your local folder; a missing styles.css or a nested path shows up immediately. Once the site is live at a temporary or supplied address, a custom domain is a separate step: you buy or transfer a domain from a registrar, then point its DNS records at the host according to the host's instructions. DNS changes commonly take anywhere from minutes to a day or so to propagate, and "it still doesn't work" during that window usually means the records are correct but caching hasn't caught up. Check with a DNS lookup tool rather than refreshing in frustration. Success check: open the published URL on a different device or network—not your own machine, where cache can mislead—and confirm the content, styles, and a working link. Where This Leads Once You've Shipped One Page The single-page workflow above scales further than people expect. Add an about.html in the same shell, link it from the homepage, and you have a multi-page site. Style a consistent header and footer by copying the markup, and the maintenance cost stays low until the copy-paste itself becomes tedious—that's the point at which templating and build tools start earning their place. Two natural next steps. First, forms. An HTML posting to a backend or a third-party form service is how a static page collects input; a form with no action attribute does nothing, and using a service means following that service's documented setup rather than improvising. Second, data. Fetching a JSON file with fetch() and rendering it into the DOM turns a static page into a small app, but it requires a local server during development, because browsers block those requests from file:// pages. A calibrated expectation about scope: hand-written HTML, CSS, and JavaScript comfortably covers personal sites, documentation, portfolios, landing pages, and small business sites. Once a page needs user accounts, a database, or frequently updated content from multiple authors, the right tool is usually a framework or content management system rather than more hand-written pages—not because hand-coding stops working, but because the maintenance burden of duplicated markup and manual updates grows faster than the feature set. The concepts in this article don't become obsolete at that boundary; frameworks ultimately produce the same HTML, CSS, and JavaScript the browser consumes, and understanding what they produce is what lets you debug them. Questions That Come Up After the First Page Do I need to learn HTML and CSS before JavaScript? Learn enough HTML to structure a page, then enough CSS to make it presentable, then JavaScript. Trying to learn all three simultaneously makes it hard to tell which layer caused a given problem, because symptoms in the browser are rarely labeled by language. Why does my page look different than I designed it on mobile? Usually a missing viewport meta tag, a fixed pixel width on a wide element, or default browser differences in margins and font sizes. Resetting common defaults at the top of the stylesheet and testing in a narrow window catches most of it. Can I build a real website without a framework? Yes—modern HTML, CSS, and JavaScript handle the overwhelming majority of small sites well. Frameworks exist to manage complexity at scale and to streamline repeated structures; they're a productivity choice, not a prerequisite. What if someone else needs to edit the page later? That's a reason to care about file organization and semantic markup now. Clear filenames, consistent indentation, meaningful class names, and proper heading structure are what make a small site maintainable by someone who didn't write it.