Back to the blog Web development

Build and Publish Your First Website: A Practical HTML and CSS Guide

Create a small, readable website from scratch. This beginner guide walks students and teachers through semantic HTML, accessible images and links, responsive CSS, browser testing, and publishing a static site with GitHub Pages.

A student and teacher reviewing a simple website on a laptop

A small project, from first file to live page

This guide is an original, beginner-friendly route to making a personal website. The project is a simple static site: HTML provides the content and structure, CSS controls its presentation, and a web host serves the finished files. Students can use a profile or class project; teachers can adapt the same steps for a supervised exercise.

You need a computer, a way to create and edit plain-text files, and a browser. A code editor is convenient but not essential. Begin with a folder named garden-site, containing index.html, styles.css, and, if needed, an images folder. Save a backup before experimenting. This lesson does not require JavaScript, a database, a paid domain, or special software.

Work in sequence: decide what the page is about, write and structure its content, add a small stylesheet, check images and links, test the result in a browser, and then publish. Change one thing at a time and reload the page so you can connect what you edited with what you see.

  • Start with one page and a clear audience; add more pages only when the content needs them.
  • Use current documentation for details that may change, especially hosting workflows.
A small project, from first file to live page

Plan the content and mark it up semantically

Before writing HTML, note the page’s purpose and draft its title, a short introduction, and a few useful sections. HTML is not just a way to make text look large or bold: elements identify what content is. Use headings for an outline, paragraphs for prose, and lists when items naturally belong together. A heading level should reflect its place in that outline, not just its default appearance.

Landmark elements make the broad structure understandable. A page-level header introduces the site or page; nav groups the main navigation links; main contains the page’s unique content; and footer holds closing information such as authorship or contact details. Use main once per page. A section groups a themed part of the page and should normally have a heading. An article is appropriate for content that could stand on its own, such as an independent post. Do not add landmarks merely for visual styling; CSS can style semantic elements directly.

Here is a complete starter file. It has a meaningful internal link to a section on the same page and an external link to a useful reference. Link wording names its destination instead of relying on “click here.” The external URL is written in the code example so it can be copied accurately.

  • Keep one clear page topic and give the document a useful title.
  • Use div only when no more meaningful element fits the purpose.
Plan the content and mark it up semantically

Add accessible images and readable CSS

Put an image file in the images folder and use a path relative to index.html, for example images/seedlings.jpg. Add alternative text based on the image’s purpose in context. For an informative photograph, describe the relevant information it contributes, such as Three bean seedlings in the sunny garden bed. Avoid generic text such as “image.” If an image is purely decorative, use an empty alternative, alt="". If an image is the only meaningful content in a link or button, its alternative should explain the destination or action. For a chart or other complex graphic, also provide the important information in page text; a short alt value cannot replace a detailed explanation.

For this project, place a photograph you have permission to publish at the stated path and insert <img src="images/seedlings.jpg" alt="Three bean seedlings in the sunny garden bed"> inside the page’s main content. The relative src path starts from index.html; the alt value communicates the photograph’s relevant content. Adapt that description to the photograph you actually use.

Connect a separate stylesheet from the document head, as in the starter file. CSS rules select elements and set property-value pairs. Save this example in styles.css:

  • Choose text and background colors with enough contrast to read; do not use color alone to convey meaning.
  • Check that text remains readable when enlarged and that links are visually distinguishable.

A flexible first stylesheet

body { max-width: 42rem; margin: 0 auto; padding: 1rem; color: #222; font-family: sans-serif; line-height: 1.6; } img { max-width: 100%; height: auto; }

The maximum width keeps long lines from becoming unwieldy on large screens, while automatic side margins center the content when there is spare space. On a narrow screen the content can use the available width, with padding around it. The image rule prevents an image from exceeding its containing area. Avoid assigning the page a fixed width that forces horizontal scrolling on phones.

To confirm that the CSS file is connected, temporarily add p { color: red; } and reload the page. If paragraph text turns red, the browser found and applied the stylesheet. Remove the test rule afterward. If nothing changes, check that styles.css is saved beside index.html, that the filename in the link element matches exactly, and that you are viewing the file you edited. Then inspect punctuation, save, and reload again.

Test the page as a reader

Open index.html in a browser after the first save, then repeat after each substantial change. Check that the title, headings, paragraphs, and image appear. If an image is missing, check both the filename and its relative path; capitalization can matter on a host even if the local computer appears forgiving. If styling does not apply, verify the stylesheet connection before rewriting rules.

Test the layout at a narrow and a wide viewport. Look for clipped text, horizontal scrolling, images that overflow, and controls or links that are difficult to use. Increase the browser zoom and make sure content remains available. Read the page in heading order, examine alternative text decisions, and activate each link. Ask another person to follow the page without your explanation; unclear navigation or wording may be easier for a fresh reader to notice.

A local browser check is useful but does not prove that every accessibility or usability need is met. The W3C Web Accessibility Initiative’s image decision tree explains when to use descriptive, empty, or functional alternatives. MDN’s learning materials offer further instruction on HTML structure and CSS. These are learning references, not a substitute for testing with people who may use the page differently.

  • Check the page at more than one width and verify that the intended content remains visible.
  • Follow internal and external links; confirm each destination and meaningful link text.
  • Review image alternatives in context, not by applying the same rule to every image.

Publish the static site with GitHub Pages

This worked route uses GitHub Pages to publish a static HTML/CSS project. It requires a GitHub account and a repository. GitHub’s current documentation should be consulted if its interface or eligibility rules change. GitHub Pages serves static files; it is not a place to run server-side PHP, Ruby, or Python. Do not assume that a repository being private makes the published page private: GitHub warns that Pages sites are publicly available on the internet.

First, create a repository for the project in GitHub. If the account is using the GitHub Free plan, the repository must be public for Pages, according to the current documentation. Before uploading, remove passwords, personal records, private student details, photographs without permission, and any other material that should not be public. A public website is a poor place for sensitive classroom information. For student work, agree on names, images, permissions, and visibility with the teacher or school before publishing.

Upload the website files to the repository using GitHub’s web interface, or another method you understand. Keep index.html, styles.css, and the images folder at the top level of the same branch for this example. In the repository’s Settings, open Pages; under Build and deployment choose Deploy from a branch, select the branch containing those files, select its root folder, and save. This uses the root-folder publishing option documented by GitHub; a /docs folder is another supported option, but is not the layout used here. If the interface labels have changed, follow the official publishing-source guide listed below. Keep the file paths in your HTML consistent with that chosen folder.

After the publishing workflow completes, use the Visit site link in the repository’s Pages settings. Open the resulting public address in a browser and check it as a visitor would: load the home page, follow each link, verify the image and CSS, and test at a narrow width. A successful local draft is not proof that the published version is correct. GitHub says changes can take up to 10 minutes to appear; if an update is still missing after an hour, consult its build-error troubleshooting guidance. Recheck the live page after every update.

  • Keep a local backup and review the exact files and paths before publishing.
  • Treat the published site as public, even when repository visibility settings differ.
  • Verify the deployed URL in a browser; do not stop at seeing a successful upload.

Final project checklist and further learning

Use this checklist before sharing a finished project. It combines content, accessibility, responsive behavior, testing, and publishing checks so that the site is reviewed as a real visitor will experience it.

  • The page has a useful title, one clear topic, a logical heading outline, and appropriate header, nav, main, and footer landmarks.
  • Each informative image has a relevant alternative; decorative images use an empty alternative; complex visual information is also available as text.
  • Internal links point to existing pages or section IDs; external links have meaningful text and lead to the intended destination.
  • The stylesheet loads, text is readable, images fit their containers, and the page works at narrow and wide widths.
  • The page has been opened in a browser, checked after saving, and reviewed by someone other than its author where possible.
  • Before publishing, permissions, privacy, visibility, and backups have been considered; afterward, the live URL and its links, images, and layout have been verified.

Authoritative learning references

For tutorials, follow MDN’s HTML and CSS lessons and GitHub’s two publishing guides in the source list. For the specifications behind the examples, use the WHATWG HTML Standard’s embedded-content chapter, the W3C CSS Snapshot, and WCAG 2.2. These standards and their maintainers are separate from this original beginner project. The HTML reference defines image fallback content, the CSS snapshot maps the language’s specifications, and WCAG describes accessibility requirements including non-text alternatives.

These references are maintained by their respective organizations and may change. This guide gives a beginner project path, not a guarantee of accessibility, privacy, security, or suitability for every class or audience. Recheck current platform requirements before publishing.

From draft to published page

A six-step review path for a beginner’s static website project.

  1. 1
    Plan

    Choose an audience, purpose, and short set of page content.

  2. 2
    Structure

    Write semantic HTML with landmarks, headings, and meaningful links.

  3. 3
    Style

    Add a separate stylesheet and flexible layout rules.

  4. 4
    Review

    Check images, link destinations, readability, and narrow-screen behavior.

  5. 5
    Publish

    Upload files and configure a static hosting source.

  6. 6
    Verify

    Open the live URL and test the published version as a visitor.

Frequently asked questions

Do I need a special program to write HTML and CSS?

No. You need a way to edit plain-text files and a browser to view them. A code editor can make editing more convenient, but the essential steps are writing, saving, and checking the files.

Should every image have descriptive alternative text?

Choose the alternative according to the image’s purpose. Informative images need text that conveys relevant meaning; decorative images should use an empty alternative. A linked image may need to communicate its destination or action. For complex graphics, make the important information available elsewhere in the page as well.

Is GitHub Pages private if my repository is private?

Do not rely on repository visibility to make a Pages site private. GitHub states that Pages sites are publicly available on the internet, even when the repository is private if the plan allows it. Remove sensitive material before publishing.

Does a page that works on my computer automatically work on a phone?

No. Check the page at a narrow viewport as well as a wide one. Use the viewport declaration, avoid fixed wide layouts, constrain images to their containers, and inspect the published page rather than relying only on a local draft.

Sources and further reading 10