
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Linking External Style Sheets in CSS
CSS allows us to link external style sheets to our files. This helps us make changes to CSS separately and improves the page load time. External files are specified in <link> tag inside <head> of the document.
Syntax
The syntax for including external CSS is as follows.
<link rel="stylesheet" href="#location">
Example
The following examples illustrate how CSS files are embedded &miuns;
HTML file
<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h2>Demo Text</h2> <div> <ul> <li>This is demo text.</li> <li>This is demo text.</li> <li>This is demo text.</li> <li>This is demo text.</li> <li>This is demo text.</li> </ul> </div> </body> </html>
CSS file
h2 { color: red; } div { background-color: lightcyan; }
Output
This gives the following output −
Example
HTML file
<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h2>Demo Heading</h2> <p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. </p> </body> </html>
CSS file
p { background: url("https://www.tutorialspoint.com/images/QAicon.png"); background-origin: content-box; background-size: cover; box-shadow: 0 0 3px black; padding: 20px; background-origin: border-box; }
Output
This gives the following output −
- Related Articles
- Importing External Style Sheets in CSS
- Embedded or internal Style Sheets in CSS
- Creating Media Dependent Style Sheets using CSS
- How to specify media dependencies for CSS style sheets
- 7 External Linking Best Practices for SEO
- Style Rules in CSS
- Font Style in CSS
- The border-style Property in CSS
- Setting List Style Type in CSS
- The outline-style Property in CSS
- CSS outline-style property
- Usage of font-style property in CSS
- Usage of border-style property in CSS
- The list-style Shorthand property in CSS
- Style select options with CSS

Advertisements