When altering the name of your CSS stylesheet, it is crucial to update the reference in your HTML code; otherwise, the old name will be referenced and cause errors. This rule applies to all file resources linked within an HTML page, including other HTML files, images, scripts, etc.
EXAMPLE OF UPDATING:
Let's consider three files: index.html
, contact.html
, and stylesheet.css
. In both index.html
and contact.html
, you may find the following code snippets:
<!-- index.html -->
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<a href="contact.html">Contact me</a>
<!-- contact.html -->
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<a href="index.html">Home</a>
Both pages are linked to the stylesheet, and each page has a link to the other page.
Now, if we decide to rename the stylesheet to awesome-style.css
and the contact page to
awesome-contact.html</code, we must update our HTML pages accordingly:</p>
<pre><code><!-- index.html -->
<link rel="stylesheet" type="text/css" href="awesome-style.css">
<a href="awesome-contact.html">Contact me</a>
<!-- awesome-contact.html -->
<link rel="stylesheet" type="text/css" href="awesome-style.css">
<a href="index.html">Home</a>
In this scenario, three lines of code needed to be modified. Every HTML page using the stylesheet must be updated to ensure consistent styling across all pages. Additionally, the link from index.html
to contact.html
was adjusted to now point to awesome-contact.html
.
No modifications were required in the actual awesome-style.css
file since it does not specify which HTML documents will utilize it.