HTML
CSS
JavaScript
jQuery
PHP
SQL
WordPress
HTML Tutorials

Overview

An external style sheet and external JavaScript file are used to define the various styles and actions respectively while keeping everything centralized. This is a best practice because if you were to place your scripts and styles directly in the head of each document, there would be no centralized location to make your changes and you’d have to search for all the various rules across multiple locations. See Placing Styles and Scripts Directly in a Document for more information.

The following shows where to place our links to our external script file(s) and CSS file(s). Typically this is done directly after the title tag, but could be placed anywhere in the head of the document.

				
					<head>
  
<meta charset="UTF-8">
<meta name="description" content="Free Web Tutorials">
<meta name="keywords" content="HTML, CSS, JavaScript, PHP, SQL">
<meta name="author" content="1SMARTchicken">
<meta name="viewport" content="width=device-width, initial-scale=1.0">


<title>Advanced HTML Template</title>


<!-- styles -->
<link rel="stylesheet" type="text/css" href="/docs/style.css">
<link rel="stylesheet" type="text/css" href="/docs/sidebar-styles.css">

<!-- scripts -->
<script src="/scripts/main.js"></script>

</head>
				
			

The link tag is used to link to external style sheets. The type attribute tells the browser what kind of document to expect and the href attribute is the target URL for where the document lives.

Similarly, the script tag is used to link to an external JavaScript file, and requires the type attribute to tell the browser to expect JavaScript and the src attribute which tells the browser where the document lives in the file structure.

Non-Crucial Scripts

Non-crucial scripts can be placed just before the closing /body tag which can speed up the page load time because the page can first render before applying the scripts.

				
					<!-- scripts -->
<script type="text/javascript" src="/scripts/main.js"></script>

</body>

</html>
				
			

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

HTML
CSS
JavaScript
jQuery
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.