Customizing Templates

Customizing an HTML Template Step by Step

Most static templates unpack into the same shape: an index.html file, a css folder, a js folder and an images folder. Once you know how those pieces connect, changing text, colors, fonts and pages is routine work.

· 5 min read

Computer screen showing colorful source code in a dark editor theme
Computer screen showing colorful source code in a dark editor theme. Photo: Chris Ried / Unsplash

Know your way around the files

A downloaded template usually arrives as a ZIP archive. Unpacked, it holds a few HTML files at the top level and folders for supporting assets. A common arrangement looks like this:

index.html
about.html
css/style.css
js/main.js
images/hero.jpg

index.html is the home page, and the server shows it when someone visits the bare address of the site. The HTML files load the stylesheet, scripts and images through relative paths such as css/style.css or images/hero.jpg. Move a file to another folder without updating those paths and the page loses its styles or shows broken images.

Open the whole folder in your code editor rather than single files. You get a file tree in the sidebar and, more usefully, a project-wide search, which you will use constantly to find where a piece of text or a class name lives.

Before you change anything, make a copy of the original folder or put it under version control. Being able to compare against the untouched version saves a lot of guesswork later.

Replace the text

Placeholder copy sits inside ordinary HTML elements. Headings use h1 through h6, paragraphs use p, and lists use ul or ol with li items. To change the words, edit the text between the opening and closing tags and leave the tags themselves alone.

Keep the heading structure intact while you do this. Each page should have one h1 for its main subject, and the levels below should follow in order. If the template uses a heading purely because of its size, it is worth fixing now: choose the level that matches the structure and adjust the size in CSS.

Update the <title> in the <head> of every page too. It is easy to forget because it is not visible on the page, yet it appears in browser tabs, bookmarks and search results.

Fix links and images

Templates often use # as a stand-in link target. Replace each one with a real destination:

<nav aria-label="Main">
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="about.html">About</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>

Think twice before opening links in a new tab. It takes control away from the visitor and can disorient screen reader users. If you do use target="_blank" for an external link, say so in the link text or with a small icon that has a text alternative.

For images, copy your files into the images folder and update the src attribute. Give the width and height attributes the real pixel dimensions of the new file, so the browser can reserve space before it loads, and write alt text that describes what the image shows:

<img src="images/studio-desk.jpg" width="1600" height="900"
     alt="Desk with a laptop, sketchbook and color swatches">

Resize photos before adding them. A phone camera image straight from the device is far larger than any template needs.

Change colors and fonts

Open the main stylesheet, often css/style.css, and look at the top of the file. Many modern templates define their colors, fonts and spacing once as custom properties inside a :root block, then reuse them throughout the file with var(). If yours does, changing the theme is a matter of editing a few lines in that block, and every button, link and heading that refers to them updates at once.

Older templates repeat the same hex values across dozens of rules. Use your editor's search to find each color and replace it consistently. This is also a good moment to check that text still stands out clearly against its new background; browser developer tools show the contrast ratio when you inspect a text color.

For fonts, a system font stack loads instantly because it uses fonts already installed on the device:

body {
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

If you prefer a web font, load one family in the two or three weights you actually use, not the full set.

Control width and spacing

Long lines are hard to read on wide screens. Most templates have a container class that caps the content width; adjust it to suit your text:

.container {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

margin-inline: auto centers the container, and the padding keeps text off the screen edges on phones.

Add pages

The quickest way to add a page is to copy an existing one. Duplicate about.html, rename the copy to something short and lowercase, such as services.html, and replace the content inside main while leaving the header, navigation and footer as they are. The new page then shares the same stylesheet, scripts and overall look.

The catch is the navigation. In a plain static site each file has its own copy of the menu, so a new page needs a new link in every file. With a handful of pages that is manageable. With many, consider a static site generator or server includes so the header lives in one place.

Test before you publish

Open each page in your browser and switch on the responsive mode in developer tools. Drag the width from phone size up to a wide desktop and check that:

  • text wraps cleanly and nothing overlaps
  • the menu stays usable on small screens
  • images shrink with their containers and never cause sideways scrolling
  • buttons and links are large enough and far enough apart to tap

Then press Tab through each page to confirm that focus is always visible and moves in a sensible order. Finally, run the pages through the W3C Markup Validation Service and the CSS validator. They catch unclosed tags, mistyped attributes and invalid property values that browsers quietly paper over until a different browser does not.

Frequently asked questions

Do I need a framework to customize an HTML template?

No. A static template needs only a code editor and a browser. You can open the files, change them and reload the page to see the result, with no build tools or database involved.

What are CSS custom properties, and why do templates use them?

Custom properties are values defined once, usually in a :root block near the top of the stylesheet, and reused with var(). Changing one definition updates every rule that refers to it, which makes color and font changes quick.

Why does a new page not appear in the menu?

In a plain static site, every HTML file contains its own copy of the navigation. When you add a page, you have to add its link to the menu in every file, or move to a setup that shares the header between pages.

How can I test the layout on phone sizes without a phone?

Use the responsive or device mode in your browser's developer tools. It lets you set any viewport width and simulate touch, which covers most layout checks. Test on a real phone before launch as well.

More in Customizing Templates