+ 3

How can I inherit the contents of one html file into another?

How can I inherit the contents of one html file into another? (I don't work with Django)

16th Aug 2023, 5:01 AM
python
9 Antworten
+ 6
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <div w3-include-html="first.html"></div> <div w3-include-html="second.html"></div> </body> </html>
17th Aug 2023, 7:25 PM
JaScript
JaScript - avatar
+ 5
Евгений , We simply have different opinions. In my opinion the answers here in Q&A are meant to encourage people to work on themselves and find solutions on their own. Serving up ready-made solutions on a platter doesn't get anyone anywhere. On the other hand, nowadays the Internet and the documentation for most programming languages and HTML are freely available. That something does not work will always happen and that can not be avoided. So you have to get along and find a solution. I succinctly pointed to one possible way in my answer above. You have dealt with it and thus I have achieved my goal. The good question would be, what has the person, who asked the question done now? She has not commented at all till now. That would mean for me it is no longer important for them. That would be a pity.
19th Aug 2023, 12:39 PM
JaScript
JaScript - avatar
18th Aug 2023, 7:16 AM
JaScript
JaScript - avatar
+ 4
Such as things will be made usually on backend site with django, flask, node, express, php and its frameworks … etc. In my opinion the question got to easier without any details. Much important is to explain what you want to do with html files and without Django, to show (beter link from SL playground) an attempts code or at least describe your input, output to that and which methods are alowed for a solution?
18th Aug 2023, 1:43 PM
JaScript
JaScript - avatar
+ 1
JaScript That's exactly the article I guessed you got your technique from and was referring to. This approach requires to include a javascript code to the html page. So you answer is incomplete, at least.
18th Aug 2023, 9:47 AM
Евгений
Евгений - avatar
0
JaScript Are you sure that will work? At the place where you probably saw this technique it is said that there should be some javascript that will do the actual include. JUMP_LINK__&&__python__&&__JUMP_LINK This can't be done without some piece of software, written in Python/PHP/Java/etc. at backend, some javascript code that you need to include to every your "template" html and that will do the actual include, or a web server supporting SSI (server-side includes). HTML is not designed to do includes. Except for frames, but they're not true includes.
17th Aug 2023, 9:10 PM
Евгений
Евгений - avatar
0
JaScript My point is that it's better not to give any advice at all than to give bad advice. Your answer is actually a bad advice (no offense). A novice that read your answer may assume that there's a native functionality in HTML that allows one to include one html page into another, and that they can just throw a simple attribute and they are fine. (See, there are 3 upvotes already on the incorrect/incomplete/misleading answer!) It's not the case, and I'd like to draw everyone's attention to this fact.
19th Aug 2023, 11:00 AM
Евгений
Евгений - avatar
0
JaScript The question, as I see it, is pretty straightforward. JUMP_LINK__&&__python__&&__JUMP_LINK being a novice, knows that html-like files like Django templates for example and many others, have a functionality to include contents of other file. So they assumed (remember, they're a rookie) that there's similar functionality in HTML itself. But it's not the case. And that is not something that it explicitly stated somewhere (in an article or a standard). And to know that, one needs to consume a lot of information from documents, code examples, own experiments. When a person comes to Q&A with a specific question popped up during their learning, it is not not a goog thing to assume that they should've learnt all the docs about HTML. They are in the process of learning, it's obvious that they haven't read the documentation.
19th Aug 2023, 1:24 PM
Евгений
Евгений - avatar
0
JaScript As for your initial answer. It's just code with no explanations or warnings about its incompleteness. It looks like "a ready-made solution on a platter", and thus everyone will perceive it lake that at first glance. But! It's not. It doesn't work it the presented form. It is missing a very important part. With the same level of success you could've wtitten: "Start with <html> <body> <div /> </body> <html> and when questions occur, consult the docs and Google". This is an exaggeration, but in essence it's the same. My plea for you is to be careful when answering in the future, and be sure that your answer is *really* a good advice and is helpful.
19th Aug 2023, 1:31 PM
Евгений
Евгений - avatar