- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the ways to include style sheet rules in an HTML document
To include stylesheet rules, use the <style> element or style attribute or even external stylesheet using <link>.
The <link> element can be used to include an external style sheet file in your HTML document.
An external style sheet is a separate text file with .css extension. You define all the Style rules within this text file and then you can include this file in any HTML document using <link> element.
Here is the syntax of including external CSS file:
<head> <link href = "..." media = "..." /> </head>
The following are the attributes of a <link> element:
Attribute | Value | Description |
---|---|---|
Type | text/css | Specifies the style sheet language as a content-type (MIME type). This attribute is required. |
Href | URL | Specifies the style sheet file having Style rules. This attribute is a required. |
media | screen tty tv projection handheld braille aural all | Specifies the device the document will be displayed on. The default value is all. This is an optional attribute |
Let us say the style is new.css:
h1, h2 { color: #36C; font-weight: normal; letter-spacing: .4em; margin-bottom: 1em; text-transform: lowercase; }
Now you can include this file new.css in any HTML document as follows:
<head> <link new = "mystyle.css" media = " all" /> </head>
- Related Articles
- Include meta data in an HTML document
- Rules to override Style Sheet Rule in CSS
- How to add CSS rules into an HTML document
- How to include Modernizr in HTML document?
- Include information about the document in HTML
- How do we include a section in an HTML document?
- What are the different ways to include dry fruits in our diet?
- How to use inline CSS (Style Sheet) in HTML?
- How to use internal CSS (Style Sheet) in HTML?
- What are the essential tags for an HTML Document?
- What are the most important tags for an HTML Document?
- How to include an acronym in HTML?
- How to include an abbreviation in HTML?
- How to include another HTML file in an HTML file?
- Style Rules in CSS

Advertisements