dotnet-practitioner
dotnet-practitioner

Reputation: 14148

html and css only: html tags reuse across different pages

How could I reuse some html and/or DIV tags across different web pages instead of copying over and over inside all the different pages.

I intend to use only html and css at this point. These pages have file extension of .html

I do not want to use any JavaScript or server side or any programming language in my web pages at this point.

Upvotes: 1

Views: 549

Answers (5)

Jeff B
Jeff B

Reputation: 30099

If you don't want to do it via CGI, PHP, etc, then your only options are iframes (shudder), or manually. Of course manually can also mean a site generator or a pre-processing script that inserts your code in between some comment tags:

<!-- STARTMENU -->
<!-- ENDMENU -->

Then write a script to look for that comment/tag and insert your code. The advantage of START/END tags is that you can leave the comments and replace your code with new code later.

Upvotes: 1

Bob Aman
Bob Aman

Reputation: 33239

Use something like webgen to build your HTML and CSS. That will allow reuse, but it all compiles down to static files and nothing more.

Upvotes: 0

ChssPly76
ChssPly76

Reputation: 100746

I would suggest looking at static site generators like webgen as that technically satisfies all your requirements.

However, it's certainly not the simplest way to go about it - SSI / php as suggested by other answers would be by far more straightforward.

Upvotes: 1

Eric
Eric

Reputation: 97641

I do not want to use any JavaScript or server side or any programming language in my web pages at this point.

Sorry, but that kinda rules out any options. Without that constraintm your best choices are php:

<?php include("randomdivs.html")?>

or SSI (shtml)

<!-- #include virtual="/footer.html" -->

Upvotes: 1

Michal M
Michal M

Reputation: 9480

By excluding programming languages you pretty much exclude the only way.

There is only one alternative though, and that's using <iframe> with your <div>.

Not willing to use any server side stuff also excludes Apache Server-Side includes which are a very neat solution with no programming knowledge required.

Upvotes: 1

Related Questions