Hey everyone i have a little problem with the navigation bar, i have created the design of the menu but i want to be in one file (menu.html) and to show on all pages in the website... here is my code for menu.html

<html>
    <body>
        <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
        <style>
            form.position-and-style {
                opacity:1;
                position:absolute;
                border-radius:20px;
                width:150px;
                left:-1%;
                top:10%;
                height:100px;
                background-color:white;
                border:1px solid gray;
            }
            #pocetna {
                opacity:1;
                position:absolute;
                top:10%;
                left:20%;
                font-feature-settings:normal;
                font-style:normal;
                font-family:sans-serif;
                font-size:15px;
            }
            #kontakt {
                opacity:1;
                position:absolute;
                top:70%;
                left:20%;
                font-feature-settings:normal;
                font-style:normal;
                font-family:sans-serif;
                font-size:15px;
            }
        </style>

        <form class='position-and-style'>
            <a id='pocetna' href='index.html'><b>Почетна</b></a>
            <a id='kontakt' href='sleden_cekor.html'><b>Контакт</b></a>
        </form>

    </body>
</html>

Tell me how can i make this menu appear on all sites i have with out copy and pasting the same code in every single page.
Thank you :)

Recommended Answers

All 10 Replies

Create file called menu.html and save above code to that file.
And include that menu.html file to every page that you want to put menu.

But how can i do that, how to include the "menu.html" file into another file for example index.html

just add below tag in pages where you want to include menu.html..

<?php include('menu.html');?>

first tell me that ? do you have any knowledge about php? it can be done using php include. :)
i have descriped above.

Im putting the php code under the first <html> tag but doesn't work please tell me where to put the code ?

<html lang=mk>
    <? php include('menu.html'); ?>
    <head>

Please i cannot make it i tryed again the same thing on the page you give me but the menu does not appear in the index.html site ...

ok..
save menu.html as menu.php
then go to index.html paste this code <?php include("menu.php");?> nd do your coding for index.html

index.html must be save as index.php also. Otherwise, anything with <?php will not be parsed by the PHP parser.

There are alternatives to .php extension. PHP parser will parse any files with these extensions

.php
.php3
.php4
.php5
.phtml
.inc // carefull with this one. the source can be viewed from the browser
.tpl

Make sure you are running PHP on your server:

## index.php ##
<html>
    <head>
    ...
    </head>
    <body>
        <?php
            include('menu.php');
        ?>
    </body>
</html>


## menu.php ##

<ul>
    <li>...</li>
    ...
</ul>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.