combining two pages in HTML - html

I'm creating a web site for an institute, since I'm new to this field I want to know whether I can create a page for header part(which containing the logo and the name of the institute) and can I combine that page to each and every page I'm creating. If it is possible suggest me how can I combine the header part & newly created page..

Surprisingly, there is no way to do that in straight HTML. Not even in HTML5.
If you are only creating a few pages, I suggest simply copy-pasting the content to each page's HTML file. Admittedly, that approach can quickly become a burden.
Some web servers will parse the HTML of a page before it is served out, look for a specific kind of HTML comment, and then interpret that as a command to insert the contents of another file. This feature is called "server-side includes" or "SSI". Some web servers, such as Apache Tomcat, have this feature but turn it off by default due to security concerns.
If you are building dynamic pages where the HTML content being served is created on-the-fly with a programming language rather than read from pre-created disk files, then you can definitely include fragments of HTML using that programming language.
I suggest you do some additional study to build up your web authoring skills. One great source of training is the book "Head First HTML with CSS & XHTML" from O'Reilly Media, Inc.

You can do pull html code from different places and merge them with php. It's been years since I've done it, so I can't get into the particulars.

Related

Do I need an HTML file for every single page on my website?

Say I have a product website, like Amazon (this is not the case, but it will help me explain my point), and I have a URL for every single product (such as with Amazon)...
Do I need to copy-paste and modify an HTML file for every single individual product page, or is there a way to use a "model" on which I can base all my other pages without recopying the whole code and modifying a few things in each?
I've just started learning HTML and web development, so bare with me if I'm asking a stupid question.
It just seems odd to me that a million-page website should host a million+ individual, nearly identical, HTML files.
Thank you very much in advance.
P.S. I'm using Amazon's brand name as an example here, and am not affiliated with anything related to it. Thank you for understanding.
No, you do not need an HTML file for every single page on your website. While you could do that, it is becomes very infeasible to manage the bigger your site becomes. On most websites you would have the following components:
A front end - consists of HTML code and usually some sort of template engine with placeholders for your data
A backend - consists of your data store (usually a database).
There will also usually be some form of API and/or middleware between your front end and backend.
If you go to https://example.com/myproductid in your browser, your computer will send that request to the web server. The web server will then retrieve your data, load it into the correct template, and serve the page to you.
In traditional HTML and PHP only websites, you would have to reload the entire page each time you went to a new product. However, you can instead use a technique called Ajax to only update certain parts of a web page rather than reloading the entire page. That way you can just update the text, images, and links that are specific to the product, and the rest of the page would stay the same. (Note: Ajax originally used XML, modern implementations usually use JSON).
Ultimately, you will want to learn some JavaScript and then start looking into various web frameworks or libraries such as ReactJS.
Not you Can have only one page for all product, but you have to make it Dynamic.
Yes you need an HTML document for your each webpage, like for Home page, contact us page you need different HTML documents

How do I reuse HTML code for different pages just like every popular website in existence?

On almost every website, they have various pages, each having the same HTML code. I strongly doubt that the creators of the websites edit the HTML code of each page, especially when users can make their own pages (like redditors making their own subreddits). These two pages from wikipedia: https://en.wikipedia.org/wiki/Synthesizer https://en.wikipedia.org/wiki/Drum_machine are different pages but they have very similar html code
And I don't even need to have users create their own pages, I just need to have multiple pages that reuse html code. https://www.apple.com/mac/ https://www.apple.com/ipad/ are clearly different pages that have different html code, but I don't think the developers would copy and paste HTML code, change it, then change the code of the headers in each page to include the new page when they have a new product.
https://getbootstrap.com/docs/4.3/getting-started/introduction/ and https://getbootstrap.com/docs/4.3/examples/ are different pages that use the same html code. What do they use? Should I learn bootstrap? I've seen websites do this way before bootstrap was made, though. What's something like this called? Do they even write in HTML or do they write in something that compiles into HTML? How am I supposed to do this very simple task that every webdev knows how to do yet I am unable to find any information on it?
I've tried searching for "Reusing HTML code" but I found nothing that answers my question. All I've seen are special cases
I'm hoping with this, I'll be able to have a website that can have multiple pages that use the same basic HTML code. If I wanted a new tab, I won't have to edit the HTML code of each page.
What you described is achieved by HTML templates and server-side scripting. The server script injects data in your HTML template, thus reusing one template for any number of pages. A template may consist of multiple parts that can be combined to achieve similarly looking yet different pages. It is called dynamic HTML.
Here is a very basic tutorial on how it works: https://www.php.net/manual/en/tutorial.php
To create a modern website you need to use a dozen different technologies together. Here is an infographic to give get idea: https://codeburst.io/the-2018-web-developer-roadmap-826b1b806e8d
They are many ways to do it!
If you are using asp.net you can use master page.
For more info : Master page demo
or else you can use php "include" statement. Suppose you created one page as header.php(header.html) and other one as footer.php(footer.html), then you just have to include those pages.
eg
<?php include 'header.php';?>
<html>your web page</html>
<?php include 'header.php';?>
Well this question is so extremely general it's hard to answer without knowing what your goal is. I highly doubt there are any web developers that develop a website from scratch anymore. Most use a content management system (CMS) which uses server side scripting to serve HTML pieces to form a website. For example header, footer, content-body I don't mean the HTML tags header and footer, although they will be part of the pieces the CMS serves. The most popular content management system is Wordpress, which is built in php. The pages don't even need to be specifically designated, they can be a list of blog posts, a picture gallery ...etc . There are many different CMS packages that serve different purposes and depend on your requirements. Wordpress is in my opinion the simplest with the lowest learning curve and is quite powerful, especially with all of the templates and plugins available. Wordpress itself is free and there are many free templates to start from. However, there are paid templates and plugins that offer additional features. The only thing that you need is php support and a hosting site.
All you need to know can be found here - https://codex.wordpress.org/Getting_Started_with_WordPress
Other content management systems include Joomla, Drupal, Magento, PrestaShop, TYPO3. Each have their advantages and disadvantages, as well as varying support for plugins and templates. Some are designed to support eCommerce sites, such as PrestaShop and TYPO3 but most CMS libraries provide support for eCommerce through plugins and templates.
Bootstrap is a framework, which is a little different from a CMS, but it offers a similar functionality. It serves different pieces or containers you design to form a website or page.
I recommend starting with Wordpress and if you have more specialized needs, check out the other options. I don't recommend you start writing php code to serve pages unless you are a very experienced php coder and even in that case why would you want to if there are so many free open source tools that have already done this for you.

iFrames in html5 more specifically in Epub3.0

This is more a theoretical question than a coding question. I am trying to create a epub, with some interactive components. Now to separate the code, I put each interactive component in a separate html file. Typical interactive components will be a questionnaire.
What will be the best way to link this to my epub, two options I am considering are:
Iframe - the interactive component will display as a part of the book, and users will seamlessly complete the activity.
External link - an Icon will be displayed in the book, which will serve as a link to a new page, this page will contain the interactive component.
I would like to keep the epub according to epub 3.0 standard.
Any suggestions or alternative solutions I can research?
Either approach is compatible with the standard since external links are allowed and scripting within an iFrame is also allowed (known as scripting in a container).
The broader question is what are you trying to achieve? If the user is sent to an external page in a browser then the browser will have to post the results back to some server since the browser can't write the results back to disk or the EPUB.
It also depends on whether the EPUB Reading System is browser-based itself or an app. It is an app then in theory the app might know how to log info locally (though that would require jumping through some hoops that could have security implications.
So what is the goal here?

How to create a template in HTML?

I started creating web pages in plain HTML. I have a header, main content and a footer. The main content is divided into two, left and right content. Everything is the same on all pages except for the right content. Now I have about 15 pages. This is very tiresome if I make some changes on the other static pages (header, footer and left side content) as I have to go through all pages.
How can I create one HTML file for each static area and how am I going to integrate it?
There are, essentially, three places you can do this:
At build time. Run a script that puts the pages together and outputs static HTML. Then upload the static HTML to the server. Back in 2013 I recommended ttree, but these days static site builders are common and more powerful. My projects tend towards Gatsby (for complex projects) and Metalsmith (for simpler ones). Jekyll is very popular (and Github provides documentation for using it with GH Pages).
At runtime on the server. This could be a simple SSI, a PHP include or a full template system (of which there are many, including Template Toolkit and mustache), possibly running inside an MVC framework (such as Catalyst or Django). This is the most common approach, it has less time between making a change and putting the result life then doing the templating at build time.
At runtime on the client. This adds a dependency on client-side JavaScript (which can be fragile and unfriendly to search engines), so I wouldn't recommend it unless you already had a server-side or build-time solution in place. Gatsby, for example, is a static site generator that builds a React frontend backed by static pages.
There are a couple of ways to do this.
If you are working purely with HTML, then you can use a 'server side include' -- this is a tag which allows you to load a file into the page (see http://en.wikipedia.org/wiki/Server_Side_Includes). Whoever is hosting your website has to support this.
<!--#include virtual="../quote.txt" -->
If youe web host happen to use PHP, you can do this using the include method (see http://php.net/manual/en/function.include.php):
<?php include('path_to_file/file.htm');?>
This will include the file at the point you place the tag. But again, whoever is hosting your site needs to support this.
There are other methods of doing this, bit these are the two I make use of.
Well... what you’re looking for is called "Master Page" and unfortunately it isn’t available in html however you can use the <iframe> tag but it would make your website look really ugly. i would suggest you to use a programming language such as PHP its much easier that way.
but if you want to use <iframe> then They’ll load remote pages into your website, so you could define a "Master Page" like this:
<body>
<div id="content">
<iframe src="content1.html"></iframe>
Now, inside of content1.html, you could just write the content without the main layout

How do I create some HTML help pages, with the same content at the top and bottom, without php or ASP etc?

I want to create some html help pages, separate html pages.
However, I want to have the same content on the top and bottom of the pages.
In the past I've used PHP or ASP, with header and footer files.
I've then had to do view source and save these pages to get what I want.
I just wondered if there an easiest way to do this ?
EDIT:
The pages are for use with software using a web object not a normal browser. So there won't be a web server
If your web server supports it, you could do server side includes
You could use frames, but it's not necessarily advisable (for one, it breaks navigation).
You could use XML files with an XSLT stylesheet to turn them into HTML documents that share similar elements.
You could use PHP or another server-side language to generate the pages, and then use a recursive download tool (such as wget) to turn them into HTML.
EDIT: you're basically asking whether the "standard-ish" subset of HTML supported by your component of choice provides a way of including data from a common file, just so you won't have to include the data in every HTML document.
The answer hovers somewhere between "no way" and "maybe your component has a few tricks to do that".
The sane thing to do here would be to have a tool generate the HTML documents from a common template. Could be XML + XSLT, PHP/ASP/whatever, or a fully-fledged CMS (this actually helps let non-technical users write the document contents).
It's awful, but you could include a JS file that uses a bunch of document.write("...") to include common elements. Not SEO friendly.