4 ms·
Is there an HTML-only way of separating menus from the html page? Similar to how external style sheets only need to be edited once to apply on all pages where i
by rchaud 4y ago
Is there an HTML-only way of separating menus from the html page? Similar to how external style sheets only need to be edited once to apply on all pages where it's linked?
Of course we all know something like:
<?php include 'menu.php' ?>
But in order to get that working, the site can no longer be HTML-only, it will need a web server and pages must be titled .php. This assumes most people are building multi-page sites, and not those one-page "link in bio" style pages.
- golergka 4y agoOnce upon a time, many years ago, web designers used iframes for this — however, this is not something I would recommend. But it is an html-only way.
- uberman 4y agoYou might check out "server side includes" if your web server supports them. Here is some apache documentation: https://httpd.apache.org/docs/current/mod/mod_include.html https://httpd.apache.org/docs/current/mod/mod_include.html
- rchaud 4y agoThis is what I was doing in 2015 when my brain was fried with HTML and CSS and I was desperate to avoid having to learn even more syntax (PHP). I remember trying something like .shtml and .dhtml. It didn't feel "real". I had never seen web pages with those extensions. Frankly, I hadn't even seen .html pages in several years because everybody edits the .htaccess file to prettify the URLs. I ended up biting the bullet and going with PHP. Surprised to learn that there still isn't anything out of the box that handles this.
- deafpolygon 4y agoThat still requires a server.
- uberman 4y agoTrue. Though How would one serve a website without a server in some capacity? SSI like those from apache acting in otherwise the most privative form of server just using paths and no routing produce the kind of repetitive HLML that iframes via the client produce.
- Phrodo_00 4y ago... Serving HTML requires a server?
- handzhiev 4y agoThere was a tech called SHTML. Still not HTML only, but pretty close.
- pjc50 4y agoThere used to be Apache server-side includes for this. It is kind of an odd omission from HTML that you can't insert a bit of DOM from a different source without Javascript.
- martinskou 4y agoIf only <frame> was'nt depricated. /s
- giaour 4y ago<iframe> isn't
- XCSme 4y agoBut isn't the performance of iframes a lot worse than simply adding a JS request?
- deafpolygon 4y agoNo, not at all. It's just "worse" because often you load a whole page. If you load only a fragment, then it's just as fast as anything else.
- giaour 4y ago<iframe> is about as close to a client-side include as you can get in standard HTML.
- tannhaeuser 4y agoHTML the markup vocabulary itself doesn't have these, which makes sense when seeing HTML as an SGML application inheriting all what SGML had to offer for transclusion using entities, and quite powerful means for content-oriented applications such as using markdown (or other custom syntax), building tables of contents/site maps, search context snippet and other summary generation, type-checked user and third-party content inclusion, etc. See [1] to get a flavor for including a shared header/menu and footer on multiple pages. [1]: http://sgmljs.net/docs/producing-html-tutorial/producing-html-tutorial.html http://sgmljs.net/docs/producing-html-tutorial/producing-htm...
- perilunar 4y ago<iframe>, <object>, and <embed> all work. But you need to add target="_parent" or target="_top" to all links. There really should be an <include> element. e.g. https://www.w3.org/TR/xinclude-11/ https://www.w3.org/TR/xinclude-11/
- ndriscoll 4y agoDepending on how far you want to stretch the definition of "HTML", this can be done with XML pages that link to XSL stylesheets to describe common layouts.