html and css only: html tags reuse across different pages
How could I reuse some html and/or DIV tags ac开发者_如何学运维ross 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.
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.
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" -->
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.
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.
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.
精彩评论