MoreLesson 179Free preview
HTML Includes
This lesson is part of How To · All levels
Summary
This lesson discusses how to include the same HTML snippet on multiple pages. HTML does not have built-in include directives like server languages, so the available options are server-side include, JavaScript fetch, iframe, or web components. Each approach has consequences on SEO, security, and server needs.
Key points
- Pure HTML does not have native include elements to insert other HTML files
- Server-side include or template engine insert HTML before a page is sent to the browser
- Fetch JavaScript can contain partial HTML, but requires a server and attention to CORS
- Iframe can embed a complete page, but it makes styling and layout integration difficult
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.