Enterprise Website Development Project
By the end of this project you will have built the front end of a multi-section corporate website the way a professional team would. It has a documented page shell, a reusable card component, an English and Hindi version, structured data, a Content Security Policy, a protected CDN script, a secure contact form and a launch checklist that every page must pass.
The company is Sahyadri Tech Services, a made-up IT services firm in Hinjewadi, Pune, run by Priya Kulkarni and Farhan Shaikh. You could swap in a hospital group in Kochi or a logistics company in Lucknow. This is the Level 3 project, so it pulls together lessons from the whole level. Project: Advanced Multi-Page Business Website built a four-page site; this one adds architecture, security, languages and quality control.
What you should know first: Professional HTML Architecture, Component-Based HTML Development, Accessibility Engineering: WCAG 2.2, JSON-LD Integration, Multilingual HTML Architecture and Content Security Policy (CSP). Other lessons are linked where they are used.
What you will build
| Section | English URL | Main job | Level 3 skills |
|---|---|---|---|
| Home | /en/ | Say what the firm does and show its services | Page shell, card component, responsive hero |
| Services | /en/services/ | One page per service, such as cloud migration | Breadcrumbs, JSON-LD @graph |
| Case studies | /en/case-studies/ | Client stories with results | Reusable cards, lazy images |
| Careers | /en/careers/ | Open jobs from the HR system | Sanitised CMS HTML, SRI script |
| Contact | /en/contact/ | Enquiry form and office address | Secure form, WCAG 2.2 checks |
Every page also exists in Hindi under /hi/. A large site is like a railway network: many stations, one timetable format, one signalling system. The shell and components are your timetable format; the policies and checks are your signalling.
Step 1: Plan the page types and the shell
Five sections, two languages and dozens of service pages sound like a lot. In fact there are only four page types: home, listing (services, case studies, careers), detail (one service, one case study) and form (contact). Build one template per type, as in Scalable Website Structure.
sahyadri-site/
partials/ head.php, header.php, footer.php (outside the web root)
public/
en/ index.html, services/, case-studies/, careers/, contact/
hi/ the same tree in Hindi
css/site.3f9a1c.css
js/cards.8b21e0.js, careers.c47d92.js, contact.51aa0f.js
img/ hero-800.avif, hero-1600.avif, ...
fonts/ mukta-devanagari.woff2
docs/patterns.html the pattern libraryThe page shell is the part every page shares. Document it at the top of the shell file, so a new developer knows the rules without asking:
<!--
PAGE SHELL v2 (Sahyadri Tech Services)
Slots: {title}, {description}, {canonical}, {lang}, {main}
Rules: one <h1> per page, inside <main>
mark the current menu link with aria-current="page"
scripts: external files only, always defer (no inline JS, the CSP blocks it)
Owner: front-end team; pattern docs in /docs/patterns.html
-->
<body>
<a class="skip-link" href="#main">Skip to main content</a>
<header class="site-header">
<a class="site-header__logo" href="/en/"><img src="/img/logo.svg" alt="Sahyadri Tech Services home" width="240" height="80"></a>
<nav aria-label="Main">...</nav>
<a class="lang-switch" href="/hi/" hreflang="hi" lang="hi">हिन्दी</a>
</header>
<main id="main">{main}</main>
<footer class="site-footer">...</footer>
</body>After this step you should have a folder tree and one shell file that every page type will include.
Step 2: A production head
The head carries most of the Level 3 work. Here is the head of the cloud migration service page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self' https://cdn.jsdelivr.net; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; form-action 'self'; base-uri 'self'; object-src 'none'; upgrade-insecure-requests">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cloud Migration Services in Pune | Sahyadri Tech Services</title>
<meta name="description" content="Move your servers to the cloud with a fixed plan, zero data loss and 24x7 support from our Hinjewadi team.">
<link rel="canonical" href="https://www.example.com/en/services/cloud-migration/">
<link rel="alternate" hreflang="en" href="https://www.example.com/en/services/cloud-migration/">
<link rel="alternate" hreflang="hi" href="https://www.example.com/hi/services/cloud-migration/">
<link rel="alternate" hreflang="x-default" href="https://www.example.com/en/services/cloud-migration/">
<link rel="stylesheet" href="/css/site.3f9a1c.css">
<script src="/js/cards.8b21e0.js" defer></script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"@id": "https://www.example.com/#org",
"name": "Sahyadri Tech Services",
"url": "https://www.example.com/",
"logo": "https://www.example.com/img/logo.png",
"address": {
"@type": "PostalAddress",
"streetAddress": "Plot 12, Phase 1, Hinjewadi",
"addressLocality": "Pune",
"addressRegion": "Maharashtra",
"postalCode": "411057",
"addressCountry": "IN"
},
"contactPoint": {
"@type": "ContactPoint",
"telephone": "+91-20-5555-0142",
"contactType": "sales",
"availableLanguage": ["English", "Hindi"]
}
},
{
"@type": "BreadcrumbList",
"@id": "https://www.example.com/en/services/cloud-migration/#breadcrumb",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.example.com/en/" },
{ "@type": "ListItem", "position": 2, "name": "Services", "item": "https://www.example.com/en/services/" },
{ "@type": "ListItem", "position": 3, "name": "Cloud migration" }
]
}
]
}
</script>
</head>Why each part is there:
- CSP meta first. A meta policy only covers content after it, so it sits right after
charset. JSON-LD is a data block, not a running script, so the policy does not block it. - One canonical, three hreflang links. The Hindi page carries the identical hreflang set and its own canonical.
- No preload for the hero image. It is a plain
<img>in the HTML, so the preload scanner finds it;fetchpriority="high"on the image is enough. deferon every script, so parsing never stops (Script Loading: Async & Defer).@graphwith@id. Every page repeats the same Organization@id, so search engines know it is one company. The last breadcrumb item has noitembecause it is the current page.
The meta tag cannot set frame-ancestors, reporting or report-only mode. When you control the server, send the policy as a header instead. In Apache it looks like this:
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; form-action 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests"A host list is acceptable for a static site. Once pages come from PHP, move to the nonce-based strict policy from the CSP lesson.
Step 3: The home page with a reusable card
The home page shows six services. Writing six cards by hand invites copy-paste drift, so the card is a component: one <template>, one function that fills it, and data as input. The live coding below is the whole home page, shell included.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>IT Services in Pune | Sahyadri Tech Services</title>
<style>
:root { --brand: #0b5394; }
body { font-family: system-ui, sans-serif; margin: 0; line-height: 1.5; color: #1f1f1f; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -60px; background: #fff; padding: 8px; }
.skip-link:focus { top: 8px; }
.site-header, main, .site-footer { padding: 12px 16px; }
.site-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; border-bottom: 1px solid #ddd; }
.site-header nav ul { display: flex; gap: 12px; list-style: none; margin: 0; padding: 0; }
a { color: var(--brand); }
a[aria-current="page"] { font-weight: 700; }
a:focus-visible, button:focus-visible { outline: 3px solid #f9a825; outline-offset: 2px; }
.hero img { width: 100%; height: auto; border-radius: 8px; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); padding: 0; list-style: none; }
.card { border: 1px solid #ddd; border-radius: 8px; padding: 16px; }
.card__title { margin-block: 0 4px; font-size: 1.1rem; }
.card__link { display: inline-block; min-block-size: 24px; padding-block: 4px; }
.site-footer { border-top: 1px solid #ddd; margin-top: 24px; }
</style>
</head>
<body>
<a class="skip-link" href="#main">Skip to main content</a>
<header class="site-header">
<a href="#main"><img src="https://course.ethicscomputer.in/assets/samples/logo.svg" alt="Sahyadri Tech Services home" width="240" height="80"></a>
<nav aria-label="Main">
<ul>
<li><a href="#main" aria-current="page">Home</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<a href="#main" hreflang="hi" lang="hi">हिन्दी</a>
</header>
<main id="main">
<section class="hero" aria-labelledby="hero-title">
<h1 id="hero-title">IT services for growing Indian businesses</h1>
<p>Cloud, security and support from our team in Hinjewadi, Pune.</p>
<img src="https://course.ethicscomputer.in/assets/samples/landscape.svg"
srcset="https://course.ethicscomputer.in/assets/samples/landscape-400.svg 400w, https://course.ethicscomputer.in/assets/samples/landscape.svg 800w"
sizes="(max-width: 600px) 100vw, 800px"
width="800" height="500" fetchpriority="high"
alt="The Sahyadri hills seen from our Pune office">
</section>
<section id="services" aria-labelledby="services-title">
<h2 id="services-title">Our services</h2>
<ul class="cards" id="service-list"></ul>
</section>
</main>
<footer class="site-footer" id="contact">
<p>Sahyadri Tech Services, Plot 12, Phase 1, Hinjewadi, Pune 411057. Phone: +91 20 5555 0142</p>
</footer>
<template id="service-card">
<li class="card">
<h3 class="card__title"></h3>
<p class="card__text"></p>
<a class="card__link"></a>
</li>
</template>
<script>
// Component: one template, one function, data in
function serviceCard({ title, text, url }) {
const card = document.querySelector("#service-card").content.firstElementChild.cloneNode(true);
card.querySelector(".card__title").textContent = title;
card.querySelector(".card__text").textContent = text;
const link = card.querySelector(".card__link");
link.href = url;
link.textContent = "Read more";
link.setAttribute("aria-label", "Read more about " + title); // unique link names
return card;
}
const services = [
{ title: "Cloud migration", text: "Move servers to the cloud with zero data loss.", url: "#services" },
{ title: "Managed security", text: "24x7 monitoring and quarterly audits.", url: "#services" },
{ title: "Help desk", text: "Support in English, Hindi and Marathi.", url: "#services" },
];
document.querySelector("#service-list").append(...services.map(serviceCard));
</script>
</body>
</html>Press Tab once: the skip link appears at the top left. Press Enter and focus jumps past the menu. You should see three service cards built from one template. Each link has a unique accessible name, such as "Read more about Cloud migration", so a screen reader's links list makes sense. Text goes in with textContent, so data from a CMS cannot inject HTML.
In production the server fills the same template, so the cards are already in the HTML for search engines and for visitors without JavaScript. The client version is for filtering and live updates. If you prefer a custom element, wrap the card in <service-card> as in Custom Elements, but keep real headings and links inside it.
Step 4: The Hindi version and the switcher
The Hindi page changes lang, every visible word, the title, the description, the canonical and the JSON-LD name values. The hreflang block stays the same.
<html lang="hi">
<head>
<meta charset="utf-8">
<!-- the same CSP meta as the English page -->
<title>पुणे में क्लाउड माइग्रेशन सेवाएँ | सह्याद्री टेक सर्विसेज़</title>
<link rel="canonical" href="https://www.example.com/hi/services/cloud-migration/">
<!-- the same three hreflang links as the English page -->
<link rel="preload" href="/fonts/mukta-devanagari.woff2" as="font" type="font/woff2" crossorigin>
</head>The font preload is justified here: the browser only finds a font after the CSS is parsed, and the Devanagari heading is often the LCP element. The switcher links point to the same page in the other language, with hreflang and lang on the link so screen readers pronounce "हिन्दी" correctly. Never redirect by IP address.
Step 5: The careers page with a protected CDN script
Job descriptions come from the HR system as HTML. Inserting that HTML directly is an XSS risk (Cross-Site Scripting (XSS) Prevention), so the page cleans it with DOMPurify 3.4.17 from a CDN. Subresource Integrity makes the browser reject the file if even one byte changes (Subresource Integrity (SRI)):
<!-- in the careers page head -->
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.4.17/dist/purify.min.js"
integrity="sha384-P0JNneQf81HOl9VwNXK76cQ9VMD6Nfsnepxb0cCOg8+UzEdzgPHAPV4wVQrvYQSx"
crossorigin="anonymous" defer></script>
<script src="/js/careers.c47d92.js" defer></script>The hash was calculated from that exact file with openssl dgst -sha384 -binary purify.min.js | openssl base64 -A. The version is pinned, so the file never changes under you. The preconnect carries crossorigin because the script is fetched in CORS mode, and a hint must match the real request (Resource Hints: Preload, Prefetch & Preconnect). Both scripts use defer, so they run in this order after parsing, and careers.js can call DOMPurify.sanitize() safely.
Step 6: The contact page with a secure form
A secure form is honest about what the browser can and cannot protect (Secure Form Handling). The browser gives good input and good errors; the server enforces every rule. The live coding below also includes a small QA script that checks the page itself.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Contact us | Sahyadri Tech Services</title>
<style>
body { font-family: system-ui, sans-serif; margin: 16px; max-width: 36rem; line-height: 1.5; }
label { display: block; margin-top: 12px; font-weight: 600; }
input, textarea, select { width: 100%; padding: 8px; font: inherit; box-sizing: border-box; }
.hint { font-size: 0.9rem; color: #555; margin: 2px 0; }
.trap { position: absolute; left: -9999px; }
.consent { display: flex; gap: 8px; align-items: start; margin-top: 12px; }
.consent input { width: auto; min-width: 24px; min-height: 24px; }
button { margin-top: 16px; padding: 10px 18px; min-height: 44px; font: inherit; }
:focus-visible { outline: 3px solid #f9a825; outline-offset: 2px; }
pre { background: #f4f4f4; padding: 10px; white-space: pre-wrap; }
</style>
</head>
<body>
<a href="#main">Skip to main content</a>
<header><nav aria-label="Main"><a href="#main">Home</a></nav></header>
<main id="main">
<h1>Talk to our Pune team</h1>
<form id="enquiry" method="post" action="/en/contact/">
<input type="hidden" name="csrf_token" value="set-by-the-server-per-session">
<label for="name">Full name</label>
<input id="name" name="name" autocomplete="name" required maxlength="80">
<label for="email">Work email</label>
<input id="email" name="email" type="email" autocomplete="email" required maxlength="120">
<label for="mobile">Mobile number</label>
<p class="hint" id="mobile-hint">10 digits, starting with 6, 7, 8 or 9</p>
<input id="mobile" name="mobile" type="tel" autocomplete="tel-national" inputmode="numeric"
pattern="[6-9][0-9]{9}" required aria-describedby="mobile-hint">
<label for="service">Service</label>
<select id="service" name="service" required>
<option value="">Choose one</option>
<option>Cloud migration</option>
<option>Managed security</option>
</select>
<label for="message">How can we help?</label>
<textarea id="message" name="message" rows="4" required maxlength="2000"></textarea>
<div class="trap" aria-hidden="true">
<label for="website">Leave this empty</label>
<input id="website" name="website" tabindex="-1" autocomplete="off">
</div>
<div class="consent">
<input type="checkbox" id="consent" name="consent" required>
<label for="consent">I agree that Sahyadri may contact me about this enquiry.</label>
</div>
<button type="submit">Send enquiry</button>
<p id="status" role="status"></p>
</form>
</main>
<footer><p>Need help now? Call +91 20 5555 0142, Monday to Saturday.</p></footer>
<button type="button" id="qa">Run QA checks</button>
<pre id="report"></pre>
<script>
document.querySelector("#enquiry").addEventListener("submit", (event) => {
event.preventDefault(); // demo only: the real form posts to the server
document.querySelector("#status").textContent = "Thank you. We will reply within one working day.";
});
document.querySelector("#qa").addEventListener("click", () => {
const results = [];
const check = (ok, text) => results.push((ok ? "PASS " : "FAIL ") + text);
check(document.documentElement.lang !== "", "html has a lang attribute");
check(document.querySelectorAll("h1").length === 1, "exactly one h1");
check(["header", "nav", "main", "footer"].every(t => document.querySelector(t)), "header, nav, main and footer landmarks exist");
const skip = document.querySelector('a[href^="#"]');
check(skip && document.querySelector(skip.getAttribute("href")), "first link is a working skip link");
check([...document.images].every(img => img.hasAttribute("alt")), "every image has alt");
const fields = document.querySelectorAll("input:not([type=hidden]), select, textarea");
check([...fields].every(f => f.labels.length > 0), "every form field has a label");
const ids = [...document.querySelectorAll("[id]")].map(el => el.id);
check(new Set(ids).size === ids.length, "no duplicate ids");
const small = [...document.querySelectorAll("button, input[type=checkbox]")]
.filter(el => { const r = el.getBoundingClientRect(); return r.width < 24 || r.height < 24; });
check(small.length === 0, "targets are at least 24 by 24 pixels (WCAG 2.5.8)");
document.querySelector("#report").textContent = results.join("\n");
});
</script>
</body>
</html>Click "Run QA checks". Every line should start with PASS. Now break something on purpose: delete the <label for="email"> line or add a second <h1>, run again and watch the matching line fail. Then try the form: an empty submit shows the browser's messages, and "12345" in the mobile field fails the pattern.
What makes this form secure, and what does not:
method="post"keeps data out of URLs and server logs, and the CSP'sform-action 'self'stops injected markup from sending the form elsewhere.maxlengthandpatterngive fast feedback, but anyone can remove them with DevTools.- The hidden CSRF token is created by the server per session and checked on submit.
- The hidden "website" field is a honeypot: people never see it, simple bots fill it, and the server quietly drops those.
- Correct
autocompletetokens let browsers fill known details, which helps with WCAG 2.2's Redundant Entry criterion.
Step 7: WCAG 2.2 checks for this site
Accessibility Engineering: WCAG 2.2 listed the new criteria. Here is where each one touches this project:
| Criterion | Where it applies | What you did |
|---|---|---|
| 2.4.11 Focus Not Obscured (Minimum) | Sticky header | Add scroll-padding-top equal to the header height |
| 2.5.8 Target Size (Minimum) | Menu links, checkbox, buttons | At least 24 by 24 CSS pixels, checked by the QA script |
| 3.2.6 Consistent Help | Phone number in the footer | Same place on every page |
| 3.3.7 Redundant Entry | Contact form | autocomplete tokens so details are not typed twice |
| 3.3.8 Accessible Authentication (Minimum) | Client portal login | Allow paste and password managers; no puzzle CAPTCHA |
Step 8: The final QA and Lighthouse checklist
Run this list on one page of each type, in both languages, before launch. The tools are explained in HTML Testing & Quality Assurance, Lighthouse & HTML Auditing and Production Deployment & Optimization.
- Validate every template in the Nu Html Checker; zero errors.
- Keyboard pass: skip link, menu, cards, form, language switch, with focus always visible and never hidden under the header.
- Screen reader pass: headings list, links list and landmarks make sense in English and Hindi.
- Lighthouse in an Incognito window, mobile settings: Accessibility, Best Practices and SEO at 90 or above, and every failed audit read, not just the score. Take the median of three Performance runs.
- Structured data: paste a service page into the Rich Results Test and the Schema Markup Validator; fix every error.
- hreflang: each language version lists the same three links, and each target URL returns status 200.
- CSP and SRI: the Console shows no CSP violations; change one character of the integrity hash on a test copy and confirm the careers script is blocked.
- Responsive: 360, 768 and 1280 pixels wide, no sideways scrolling, and
srcsetdelivering the smaller image on phones. - Production: minified hashed files, Brotli or gzip, HTTPS with redirects, a real 404 page,
robots.txtand a sitemap with both languages.
Common mistakes
- Copying the shell instead of including it. Twenty pages drift apart within a month.
- Different hreflang sets on each language. Every version must list all versions, including itself.
- Inline scripts on a page with a strict CSP. They are blocked; move them to deferred files.
- An SRI hash for
@latest. The file changes and the hash fails; always pin the version. - Treating
patternandmaxlengthas security. They are user help. The server enforces the rules.
Interview questions
1. How would you structure the HTML of a 200-page corporate site?
I would group pages into a few page types and build one template per type on a shared, documented shell with skip link, landmarks and partials for header and footer. Repeated UI becomes components from templates or custom elements, documented in a pattern library. URLs, folders and naming conventions are agreed before building.
2. Why use @graph and @id in JSON-LD?
@graph puts several linked items in one block, such as an Organization and a BreadcrumbList. A stable @id names an entity, so every page refers to the same company instead of describing a new one each time.
3. What can a CSP meta tag not do that the header can?
It ignores frame-ancestors, reporting directives and sandbox, cannot run in report-only mode, and only covers content after the tag. Use the header whenever you control the server.
4. What does SRI protect against, and what does it not?
It protects against a CDN file being changed, because the browser compares its hash and refuses a mismatch. It does not make a library safe to use, and it cannot protect files that change for every visitor, such as analytics loaders.
5. Which WCAG 2.2 criteria matter most for a corporate contact page?
Target Size (Minimum) for buttons and checkboxes, Redundant Entry through autocomplete, Consistent Help for the contact details and Focus Not Obscured under a sticky header. Accessible Authentication matters for any login page.
Key points
- Plan page types first, then one documented shell and one template per type.
- Build repeated UI as components from a
<template>or a custom element, filled withtextContent. - The head carries CSP, canonical, hreflang, hints, deferred scripts and a JSON-LD
@graph. - Send CSP as a header when you can; the meta tag cannot set
frame-ancestorsor reporting. - Pin CDN scripts to an exact version and protect them with
integrityandcrossorigin. - A secure form gives good browser feedback, but the server checks every field, the CSRF token and the rate limit.
- Launch only after the QA list passes on every page type in every language.
Exercise
Build the "Doctors" listing page for a made-up Kochi hospital group, Periyar Care, in English, with a Malayalam version planned at /ml/. Include: the documented shell with a skip link and landmarks; a <template> doctor card (name, speciality, OPD days, "Book appointment" link with a unique accessible name) filled from an array of three doctors; a head with a CSP meta tag, canonical, hreflang for en, ml and x-default, and a JSON-LD @graph with an Organization and a BreadcrumbList (Home > Doctors).
Show solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; img-src 'self' data:; form-action 'self'; base-uri 'self'; object-src 'none'">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Our Doctors | Periyar Care Hospitals, Kochi</title>
<link rel="canonical" href="https://www.example.com/en/doctors/">
<link rel="alternate" hreflang="en" href="https://www.example.com/en/doctors/">
<link rel="alternate" hreflang="ml" href="https://www.example.com/ml/doctors/">
<link rel="alternate" hreflang="x-default" href="https://www.example.com/en/doctors/">
<script src="/js/doctors.js" defer></script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{ "@type": "Organization", "@id": "https://www.example.com/#org", "name": "Periyar Care Hospitals", "url": "https://www.example.com/" },
{ "@type": "BreadcrumbList", "itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.example.com/en/" },
{ "@type": "ListItem", "position": 2, "name": "Doctors" }
] }
]
}
</script>
</head>
<body>
<a class="skip-link" href="#main">Skip to main content</a>
<header><nav aria-label="Main"><a href="/en/">Home</a> <a href="/en/doctors/" aria-current="page">Doctors</a></nav></header>
<main id="main">
<h1>Our doctors</h1>
<ul id="doctor-list"></ul>
</main>
<footer><p>Emergency: call 0484 555 0100, 24 hours.</p></footer>
<template id="doctor-card">
<li><h2 class="name"></h2><p class="speciality"></p><p class="days"></p><a class="book"></a></li>
</template>
</body>
</html>// /js/doctors.js (deferred, so the DOM is ready)
const doctors = [
{ name: "Dr Meera Nair", speciality: "Cardiology", days: "Mon, Wed, Fri" },
{ name: "Dr Rohan Menon", speciality: "Orthopaedics", days: "Tue, Thu" },
{ name: "Dr Isha Thomas", speciality: "Paediatrics", days: "Mon to Sat" },
];
const template = document.querySelector("#doctor-card");
for (const d of doctors) {
const card = template.content.firstElementChild.cloneNode(true);
card.querySelector(".name").textContent = d.name;
card.querySelector(".speciality").textContent = d.speciality;
card.querySelector(".days").textContent = "OPD: " + d.days;
const link = card.querySelector(".book");
link.href = "/en/appointments/?doctor=" + encodeURIComponent(d.name);
link.textContent = "Book appointment";
link.setAttribute("aria-label", "Book appointment with " + d.name);
document.querySelector("#doctor-list").append(card);
}The script is an external deferred file because the CSP allows only 'self' scripts. Each card has its own heading and a link with a unique accessible name, and all data goes in with textContent.
Quick Quiz
1. Where should a CSP meta tag go?
A meta policy only applies to content that comes after it.
2. A careers page loads DOMPurify from a CDN with SRI. Which attributes are required?
Cross-origin files need CORS mode for the browser to check the hash.
3. The English and Hindi versions of a page each need which hreflang links?
Every version lists all versions, including itself and x-default.
4. Which field stops simple bots without bothering real users?
People never see or fill the honeypot; simple bots do, so the server can drop those submissions.
Learn HTML with a mentor
Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
