Gregorio246
Gregorio246

Reputation: 599

How to manage elements that are the same across multiple pages

Brand new to html/css, is there a way to manage recurring elements on a site such as a toolbar? For example, if I have a website with 10 pages and want to change the HTML for the universal toolbar, do I have to change it on all 10 pages?

Upvotes: 4

Views: 3377

Answers (4)

Adam Chysky
Adam Chysky

Reputation: 386

You have few options:

  1. Use some server-side language (i.e. PHP) - recommended
  2. Use iframe tag:

    <iframe src="toolbar.html"></iframe>

Upvotes: -2

pedrum golriz
pedrum golriz

Reputation: 512

If you mean having recurring items check out Madara's answer. If you mean recurring styles, the following will give you an example:

If you want a certain text to show up as red every time, you can name it "Red":

In css:

.red{
color: red;
}

The "." indicates its a recurring element and you can name it whatever you want as long as its being used in the html.

In html:

<span class="red">Sample text</span>

Upvotes: 0

Madara&#39;s Ghost
Madara&#39;s Ghost

Reputation: 174957

The easiest way would be a server-side include.

Meaning, you have:

  • index.php
  • head.php
  • footer.php
  • nav.php

And in index.php you looks something like:

<?php include_once "head.php"; ?>
Actual content here
<?php include_once "footer.php"; ?>

head.php for example, would look like:

<!doctype HTML>
<html>
<head>
    <title>Hello</title>
    <?php include_once "nav.php"; ?>
</head>
<body>

Upvotes: 7

Venkata Krishna
Venkata Krishna

Reputation: 15112

Depends. If the HTML is written in 10 different places then Yes, you have to change it on all 10 pages. If you're adding the HTML to all pages through a common usercontrol(if you are .net that is) or using a template, then you can do it in 1 place & be done with it.

Upvotes: 0

Related Questions