Linking Resources

Download html eBook

Introduction

While many scripts, icons, and stylesheets can be written straight into HTML markup, it is best practice and more efficient to include these resources in their own file and link them to your document. This topic covers linking external resources such as stylesheets and scripts into an HTML document.

Syntax

  • <link rel="link-relation" type="mime-type" href="url">
  • <script src="path-to-script"></script>

Parameters

AttributeDetails
charsetSpecifies the character encoding of the linked document
crossoriginSpecifies how the element handles cross origin requests
hrefSpecifies the location of the linked document
hreflangSpecifies the language of the text in the linked document
mediaSpecifies on what device the linked document will be displayed, often used with selecting stylesheets based on the device in question
relRequired. Specifies the relationship between the current document and the linked document
revSpecifies the relationship between the linked document and the current document
sizesSpecifies the size of the linked resource. Only when rel="icon"
targetSpecifies where the linked document is to be loaded
typeSpecifies the media type of the linked document
integritySpecifies a base64 encoded hash (sha256, sha384, or sha512) of the linked resource allowing the browser to verify its legitimacy.

Related Examples

Stats

271 Contributors: 20
Wednesday, December 28, 2016
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook