I have created 3 different html, css and javascript files but I am now confuse how can I interlink them and upload as a single file
CodePudding user response:
Looks like you're just getting introduced to web development, these might come in handy for finding out how to bring your HTRML, JS and CSS files together:
- (Link JS File) - https://www.w3schools.com/tags/att_script_src.asp
- (Link CSS file) - https://www.w3schools.com/tags/tag_link.asp
- https://www.w3schools.com/
CodePudding user response:
To inter-link different HTML files together, you can just use Hyperlink, Hyperlinking is a feature of HTML to link multiple documents (HTML) files together. It'll show up as a button on your HTML.
Here's an example of how you can implement it. href="your-path-to-your-html"
<a href="school.html" title="School">Click here to visit school</a>
<a href="inventory.html" title="Inventory">Click here to visit inventory</a>
<a href="battle.html" title="Inventory">Click here to visit battle</a>
To understand more about hyperlinking, you can read this for better examples: https://www.w3schools.com/htmL/html_links.asp
CodePudding user response:
In order to make your codes to be run by browser you need to include all your sources in one .html
file. You need to link those files inside this file and there are different requirement of each file extensions to be included.
In order to link CSS file you use link
element with src
attribute to indicate the source of your file. Another attribute rel
defines the relationship between a linked resource and the current document. In here it is stylesheet document and need to get this value.
Sample: <link rel="stylesheet" href="styles.css">
In order to link your JS file, you need to use element which is used to define a client-side script (JavaScript). You may add it internally or externally. According to your question you need to add it externally. First, add your script
element and then refer to it using the src
attribute in the script
tag.
Sample: <script src="myJSFile.js">
Resources for learning more in these topics:
https://www.w3schools.com/tags/tag_link.asp
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel
https://www.w3schools.com/tags/att_script_src.asp