A little background first. I do SEO and web work for two very different businesses: Vinsafe, which handles fire safety equipment and maintenance, and Vingrace, which installs stairlifts and home elevators. One keeps buildings safe from fire, the other helps elderly and disabled people move around their homes. Different products, same kind of customer question: "Which one is right for my building?"
For fire safety, that question usually sounds like this: "Which fire extinguisher do I need for this room?" Most answers online are long PDFs. So I built a tiny tool to answer it, and it turned out to be a really nice beginner project.
In this tutorial we'll build that Fire Extinguisher Selector with plain HTML, CSS and JavaScript. You pick the type of space and what could burn there, and the page suggests the right extinguisher types. No frameworks, no build step, around 160 lines of code in total.
You'll practise objects, arrays, filter(), form inputs and updating the DOM. Let's go.
What we're building
- A form with a space type dropdown (office, kitchen, server room, etc.)
- Checkboxes for what can burn (paper, liquids, gas, electrical, cooking oil, metals)
- A result card that lists suitable extinguisher types, plus warnings for the wrong ones
Step 1: The fire class data
Fires are grouped into classes based on the fuel. Indian standards (IS 15683 and IS 2190) and NFPA use very similar groups, so we'll store them as a simple object:
const FIRE_CLASSES = {
A: { label: "Paper, wood, cloth, plastic" },
B: { label: "Petrol, diesel, paint, solvents" },
C: { label: "LPG and other flammable gases" },
D: { label: "Burning metals (magnesium, lithium)" },
E: { label: "Live electrical equipment" },
K: { label: "Cooking oil and fat" },
};
Now the extinguisher types. For each one we store which classes it works on (classes) and where it is actually dangerous (unsafeOn):
const EXTINGUISHERS = [
{ name: "Water / Water Mist", classes: ["A"], unsafeOn: ["B", "E", "K"] },
{ name: "Mechanical Foam (AFFF)", classes: ["A", "B"], unsafeOn: ["E", "K"] },
{ name: "ABC Dry Powder", classes: ["A", "B", "C", "E"], unsafeOn: [] },
{ name: "CO2", classes: ["B", "E"], unsafeOn: [] },
{ name: "Clean Agent", classes: ["A", "B", "E"], unsafeOn: [] },
{ name: "Wet Chemical", classes: ["K"], unsafeOn: [] },
{ name: "Class D Powder", classes: ["D"], unsafeOn: [] },
];
"Doesn't cover" and "dangerous" are different things. CO2 won't put out a cooking oil fire well, but water can make one explode. That's why we keep two lists.
Keeping the data separate from the logic makes it easy to update later, for example if you want to load it from a JSON file.
Step 2: The HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fire Extinguisher Selector</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<main class="card">
<h1>Fire Extinguisher Selector</h1>
<label for="space">Type of space</label>
<select id="space">
<option value="">Choose one</option>
<option value="office">Office</option>
<option value="kitchen">Commercial kitchen</option>
<option value="server">Server / electrical room</option>
<option value="warehouse">Warehouse</option>
<option value="home">Home</option>
</select>
<fieldset>
<legend>What can burn here?</legend>
<div id="fuels"></div>
</fieldset>
<button id="check">Suggest extinguishers</button>
<section id="result" aria-live="polite"></section>
</main>
<script src="script.js"></script>
</body>
</html>
The aria-live="polite" attribute makes screen readers announce the result when it changes, which is a small accessibility win.
Step 3: Pre-select fuels by space type
When someone picks "Commercial kitchen", it's helpful to tick the likely fuels for them. A small mapping does this:
const SPACE_DEFAULTS = {
office: ["A", "E"],
kitchen: ["A", "K", "E", "C"],
server: ["E"],
warehouse: ["A", "B"],
home: ["A", "K", "E"],
};
const fuelsBox = document.getElementById("fuels");
// Build the checkboxes from FIRE_CLASSES
Object.entries(FIRE_CLASSES).forEach(([code, info]) => {
const id = `fuel-${code}`;
fuelsBox.insertAdjacentHTML(
"beforeend",
`<label class="fuel"><input type="checkbox" id="${id}" value="${code}"> ${info.label}</label>`
);
});
document.getElementById("space").addEventListener("change", (e) => {
const defaults = SPACE_DEFAULTS[e.target.value] || [];
fuelsBox.querySelectorAll("input").forEach((box) => {
box.checked = defaults.includes(box.value);
});
});
The user can still change the checkboxes. The defaults are just a starting point.
Step 4: The matching logic
An extinguisher is a good fit if it covers at least one selected fire class and is not dangerous on any of them. If it covers something but is dangerous on another fuel in the same room, it goes into a warning list. Water in a room with live electrical equipment is the classic example.
function suggest(selected) {
const good = [];
const avoid = [];
EXTINGUISHERS.forEach((ext) => {
const covers = selected.filter((c) => ext.classes.includes(c));
if (covers.length === 0) return;
const danger = selected.filter((c) => ext.unsafeOn.includes(c));
if (danger.length > 0) {
const what = danger.map((c) => FIRE_CLASSES[c].label.toLowerCase()).join("; ");
avoid.push(`${ext.name}: unsafe on ${what}`);
} else {
good.push({ name: ext.name, covers });
}
});
// Extinguishers that cover more classes go first
good.sort((a, b) => b.covers.length - a.covers.length);
return { good, avoid };
}
Step 5: Render the result
document.getElementById("check").addEventListener("click", () => {
const selected = [...fuelsBox.querySelectorAll("input:checked")].map((b) => b.value);
const result = document.getElementById("result");
if (selected.length === 0) {
result.innerHTML = "<p>Please tick at least one fuel type.</p>";
return;
}
const { good, avoid } = suggest(selected);
result.innerHTML = `
<h2>Suitable types</h2>
<ul>${good.map((g) => `<li><strong>${g.name}</strong> (Class ${g.covers.join(", ")})</li>`).join("")}</ul>
${avoid.length ? `<h2>Avoid</h2><ul class="warn">${avoid.map((a) => `<li>${a}</li>`).join("")}</ul>` : ""}
<p class="note">This is a learning project, not a safety assessment. Real sites need a survey by a qualified person.</p>
`;
});
Note that we render into the page instead of using alert(). It keeps the result visible and works better on mobile.
Step 6: A little CSS
body {
font-family: system-ui, sans-serif;
background: #f6f6f6;
margin: 0;
padding: 2rem 1rem;
}
.card {
max-width: 560px;
margin: 0 auto;
background: #fff;
padding: 1.5rem;
border-radius: 12px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
select, button {
width: 100%;
padding: 0.6rem;
margin: 0.4rem 0 1rem;
font-size: 1rem;
}
.fuel {
display: block;
margin: 0.3rem 0;
}
button {
background: #c62828;
color: #fff;
border: none;
border-radius: 8px;
cursor: pointer;
}
button:hover {
background: #8e0000;
}
.warn li {
color: #8e0000;
}
.note {
font-size: 0.85rem;
color: #666;
}
Testing it
Try a few combinations:
- Server room (electrical only): ABC Powder, CO2 and Clean Agent show up. In real server rooms CO2 or clean agent is preferred, because powder leaves residue on electronics. That's a good rule to add next.
- Commercial kitchen: ABC Powder, Clean Agent, CO2 and Wet Chemical show up, while Water and Foam go into the "Avoid" list.
- Warehouse (solids + liquids): ABC Powder and Foam come first, and Water is flagged because of the liquids.
If the results look right, deploy it for free on GitHub Pages or Netlify.
Where the data comes from
The fire classes and extinguisher pairings follow the Indian standards IS 15683 and IS 2190 (from the Bureau of Indian Standards) and NFPA 10. I kept the data small on purpose. In real projects, the fire safety team decides the final list after a site survey, and the code just makes it easy to look up.
Ideas to extend it
- Load
EXTINGUISHERSfrom a JSON file so non-developers can update it - Add capacity suggestions (2 kg, 4 kg, 6 kg) based on room size
- Save past checks in
localStorage - Add a printable checklist view for facility teams
- Reuse the same pattern for other "which one fits?" questions. A fun next version: suggest a stairlift type from the staircase shape (straight, curved, outdoor). It's the exact same logic: a few inputs, a small data table, and a filter.
Wrapping up
The best beginner projects solve a question real people actually ask. This one takes an afternoon, teaches you the basics of data-driven UI, and is genuinely useful to a school admin or a small shop owner.
If you build it, I'd love to see your version. And if you'd add a rule I missed, drop it in the comments.
Top comments (0)