Why do we need external CSS and JS files

Why We Have External CSS and JS Files

In this article, we’ll learn about CSS and JS files. We’ll explore their functions and the different ways to use them in HTML documents. After understanding all of this, we’ll understand why we have external CSS and JS files.

CSS stands for Cascading Style Sheets. CSS is used to apply styles to your websites and web pages. It’s used to make web pages easier to understand, more presentable, and more appealing to users. CSS files can be created using any text editor but must be saved with the .css extension.

A simple HTML file gives you a webpage with unorganized information. To organize this information and display it appropriately, we use CSS files. Some uses of CSS include selecting background colors, font sizes, font colors, document widths, and more.


There are three ways to use CSS in an HTML document:

Inline – In inline CSS, we use CSS properties within the tag, and each element’s CSS properties are attached to that element itself.

Internal or embedded – In internal CSS, we use CSS properties within the header section of the HTML document. We must create a <style> tag within the header section, which contains all the styles for the HTML document.

External – In external CSS, we define a separate CSS file outside the HTML document that contains all the styles for the web page. We use the <link> tag to link the external CSS file to the HTML file, obtaining all the CSS properties applied to the HTML tags.

Example

<!DOCTYPE html> 
<html> 
<head> 
<title>External CSS</title> 
<link rel="stylesheet" href="file.css"> 
</head> 
<body> 
<h1>Computer Science </h1> 
<p>It is the most evolving sector of the industry and there are lot of job opportunities in this field in upcoming years.</p>

</body>

</html>

JS

JS stands for Java Script. It is a web programming language used to give web pages custom behavior. By using JS, we can add interactivity to websites, making them visually appealing and engaging, and adding numerous features to enhance the user experience. There are two main ways to use JS within HTML files:

  • Internal JS – In this method, we utilize the

Leave a Reply

Your email address will not be published. Required fields are marked *