I need help putting in different pages into my website

I am trying to use JS, but it is not letting me. Is there a way to do it with HTML?

What do you mean “it is not letting me”? What isn’t letting you do what?

So, I a using VS Code for my editor, and, when I put JS into my website to make different pages like using, “document.innerHTML.content” and stuff like that, it says that is a security breach and it wont execute it. Is there a way to make different pages of a website with HTML and no JS?

This is how you normally make webpages, this is literally what HTML is for

I mean, how do I make like a separate page on the same site. Like, if I was making a store, I would want a products page and a home page and a cart and stuff like that

I know how to do it in JS, I was just wondering if there was a way to do it with HTML alone

i am sure 99% of every website on the internet does it with HTML , just create another HTML document inside the same folder, for example, Contact.html and link it to your index.html with an anchor tag (a), even if you have 100 pages on your website, this is how I would do it.

home.html, products.html, etc. Just to reiterate, this is how 99% of the websites on the internet work. They will generally use a web framework to generate those HTML pages, but they are still just HTML pages. For stuff which just needs to be a single page application, or part of a site that just needs to be a single page, yes, JS is often used to create the HTML, but for seperate HTML pages you create seperate HTML pages

You can use anchor tags,
<a href="link-you-want-to-go-to"></a>

Hello there ~

This link will also help you.

I am curious what you mean by you know how to do it with JS. There are ways but they are several orders of magnitude more complicated than using HTML files, which is trivially simple and one of the first things you should be learning when you learn HTML – it’s ultra basic

<a href="about.html">This is a link to the about page, it refers to a file called about.html</a>

Well, I learned how to do it in JS, but I never learned how to do it in HTML.

Thank you for the help!!!

@Eprince; How would I link the new file to the original one?

What I’m trying to understand is what you mean by you learned to make different pages using JS. JS, as used in a browser, doesn’t really have that ability. You can manipulate things on a single web page with it, but you can’t [normally] use it to make a website with separate web pages.

Say you have two HTML files in a folder. You call one about.html and one contact.html.

In about.html, if you have <a href="contact.html">Contact</a>, that will be an anchor element, when a user clicks it it will cause the browser to get the contact page.

In contact.html, if you have <a href="about.html">About</a> that will be an anchor element, when a user clicks it it will cause the browser to get the about page

1 Like

To do this we need an anchor tag, which is denoted by <a> tag and the syntax goes as follows:
<a href="contact.html">Contact Us</a> ,
In this example, I am linking to another HTML file that I created that has a file name of contact.html. and when someone clicks on the Contact Us on my main home page, it will take them to the Contact us page provided both of them are in the same folder.
<a> tag can be added to any element on your page, even to a picture, any element that is wrapped with <a> tag becomes a link that can be clicked and linked to something else as far as the href attribute is specified.
You can also use the <a> tag to jump around different sections of the same page by adding the Id value of that section to the href of the <a> tag… Eg:
<a href="#contact"><contact us</a> where the #contact is an id of a contact page on the same HTML file of the home page(webpage where every section can be seen by scrolling).

You can also use the target attribute with the <a> tag to control how the next page that you linked to will be opened… Eg:

target="_blank" would open the linked page in a new browser and so are the others below with different functions. try them out:

_parent
_self
_top

1 Like

Thank you both for your help!!

I tried your suggestions, and they worked!! Thank you so much.

you are welcome mate, enjoy your codding.

1 Like