CSS Prefixes Explained: A Practical Reference for Modern Web Devs

:artist_palette: Page-Specific CSS Prefixing Guide

Why manual prefixing still matters (and how to do it right)
:page_facing_up::light_bulb::wrench::pushpin:


If you’ve ever debugged conflicting styles across different pages, you know how fast things go sideways. This guide is for developers who work manually, not with automated CSS-in-JS tools or bundlers. It explains a real-world approach to CSS prefixing — the one used on AyotteConsulting.com as of April 21, 2025.

Disclaimer:
This guide reflects my personal methodology based on building, maintaining, and troubleshooting many real-world websites — both public and private. It’s not theoretical or based on automated tools. These rules have been field-tested for clarity, consistency, and long-term maintainability. Your mileage may vary, but this structure has saved me countless hours.

:compass: Why Prefix CSS Per Page?

Because it prevents:

  • Class name collisions across pages
  • Accidental overwrites during layout changes
  • Headaches when debugging or scaling the site

And it ensures:

  • Visual consistency
  • Clean, readable CSS
  • Simpler maintenance

:open_file_folder: The Only Global Classes Allowed

Only these may be unprefixed:

  • Navigation-related classes (e.g. .nav-container, .nav-link)
  • Footer-related classes (e.g. .footer-block, .footer-note)

All other styles must be prefixed.

:white_check_mark: The nav and footer are modular components. They’re inserted into pages via <div id="navbar"></div> and <div id="footer"></div> using a small JavaScript fetch() routine.


:label: Prefixing Rules

Every page gets its own prefix. Follow this format:

Page File Required Prefix
index.html index-
about.html about-
ebooks.html ebooks-
ventures.html ventures-
Any internal page Use matching prefix

:hammer_and_wrench: Correct vs Incorrect Usage

:cross_mark: Incorrect:

<div class="hero-section"></div>
.hero-section {
  padding: 2rem;
}

:white_check_mark: Correct (for index.html):

<div class="index-hero-section"></div>
.index-hero-section {
  padding: 2rem;
}

:construction: Work Process

  1. Work one page at a time.
  2. Prefix every class except nav/footer.
  3. Visually test changes.
  4. Never leave a page half-converted.
  5. Commit only when everything checks out.

:warning: What Happens If You Ignore This?

  • CSS bleed between pages
  • Broken layout and inconsistent visuals
  • Debugging ■■■■
  • Risk of being removed from future web tasks

:backhand_index_pointing_right: This isn’t optional. It’s the house standard.


:date: Reference Date & Source

This guide is based on:

AyotteConsulting.com CSS Prefixing Reference
https://ayotteconsulting.com/css-prefixing-reference.html
Last updated: April 21, 2025


:speech_balloon: Questions or Examples

Post your questions or share prefixing examples in the forum topic below this guide. Let’s make sure every page stays clean, scoped, and conflict-free.