xdl
xdl

Reputation: 1110

How to apply same content to multiple html pages

I'm new to html and was wondering if there is a way to apply the same content to many html files at once.

For example, if I have many pages, but all those pages have an identical navigation side panel that contains links to all the other pages. Is there any way to change the contents of this side panel without changing it for each individual page? i.e. is there a feature that allows me to make this navigation panel in a separate file, then tell all my pages to include this navigation file?

I know a css file can control the format of many html pages - is there an analogy to this that can control the content of many html pages?

Upvotes: 12

Views: 25390

Answers (4)

O.Badr
O.Badr

Reputation: 3121

You can write the common content in javascript file and include it in your html pages using script tag:

<script src="YOUR_FILE.js"></script>

You can use an online HTML to Javascript converter like this one to generate you javascript code.

Upvotes: 4

Subash
Subash

Reputation: 7256

You can use PHP to do that. Write the HTML code in PHP file, then add include statement in your HTML. This saves you from having to write same code again and again specially for navigation, etc.

PHP manual explains it.

Hope it helps.

Upvotes: 10

Cjueden
Cjueden

Reputation: 1200

<?php
include(file with extension);

?>

You'd have to change your file extension that runs this code to DOT php

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691715

Server-side includes or server-side programming languages (like PHP, for example), are often used to do that. All pages just include a shared common file, which contains the common content.

Upvotes: 1

Related Questions