Pub Pixel Avatar Image

HTML5 Snippets - Link Your Web Page To An External CSS Style Sheet That Will Always Be Applied To Your Web Page

Published:

Rate Article (Sign in and be the first to rate this article.)

Article Details

Views: 1008

First Published:

Word Count: 653

Edition: 1

Now lets say that you have some CSS style rules stored in a CSS style sheet file that you always want to have applied to your web page along with other active CSS style sheets that are also being applied to the same web page. In-order to tell the browsers that you would like to always have your style sheet applied to your web page, which is also known as a persistent style sheet. You will need to include the <link> element along with rel attribute, type attribute and the href attribute.

Now the <link> element will define the relationship between the web page the <link> element is placed in to the CSS style sheet file the <link> element links to. You will then need to include the stylesheet value for the rel attribute in-order to define the relationship between the current web page and the linked CSS style sheet file. Next you will need to add the type attribute. The type attributes value should be the MIME type of the linked document. MIME is short for (Multipurpose Internet Mail Extensions), which is an internet standard that is used to identify the type of information that the linked file contains. In our case we will need to include the MIME type value text/css for the type attribute, which indicates that the linked document is an external CSS style sheet. Next you will need to add the href attribute. The href attributes value should be the URL to your persistent style sheet file.

It's important to remember that you will need to place the <link> element within the <head> element of the web page in-order for your <link> element to work properly.

Now let me first show you the code by itself for the HTML snippet for linking your web page to an external CSS style sheet that will always be applied to your web page using the <link> element. And then I will show you how to code and where to place the HTML snippet for both HTML5 and XHTML5.

Here is the HTML code snippet below to link your web page to an external CSS style sheet that will always be applied to your web page using the <link> element.


<link rel="stylesheet" type="text/css" href="http://www.example.com/your-persistent-style-sheets-location.css" />

Here is the HTML code snippet to link your web page to an external CSS style sheet that will always be applied to your web page using the <link> element for HTML5 in the example below.


<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>Welcome To HTML5</title>
 <link rel="stylesheet" type="text/css" href="http://www.example.com/style-rules-that-are-always-applied.css">  
</head>
<body>
  
 <p>Your web page should now be linked to an external style sheet that will always be applied to your web page.</p>  

</body>
</html>

And here is the HTML code snippet to link your web page to an external CSS style sheet that will always be applied to your web page using the <link> element for XHTML5 in the example below.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  
<head>
 <meta charset="UTF-8" />
 <title>Welcome To XHTML5</title>
 <link rel="stylesheet" type="text/css" href="http://www.example.com/style-rules-that-are-always-applied.css" />  
</head>
<body>

 <p>Your web page should now be linked to an external style sheet that will always be applied to your web page.</p>  

</body>
</html>

Article Tags

Tag Article (Sign in if you want to tag this article.)

Share This Article

Send To Facebook Link

Tweet This Link

Send To LinkedIn Link

Send To StumbleUpon Link

Digg This Link

Send To Google Plus One Share Link

Send To Reddit Link

Send To Tumblr Link

Send To Delicious Link

Send To FriendFeed Link

Send To Diigo Link

Email Link

AddThis Link

0 Comments

Leave Comment (Sign in and be the first to comment on this article.)

Important

This site cannot guarantee the accuracy of articles, comments, answers and other types of content or media submitted by members or anonymous users and guests, and we recommend that you use common sense when following any advice or information found on this site. Read our full Content Disclaimer Agreement for further information.