
- 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
Importing External Style Sheets in CSS
We can import additional CSS files inside another CSS declaration. The @import rule is used for this purpose as it links a stylesheet in a document. This is generally used when one stylesheet is dependent upon another. It is specified at the top of the document after @charset declaration inside <head>.
Syntax
The syntax of @import rule is as follows
@import /*url or list-of-media-queries*/
The media queries can be compound statements which may specify the behavior of the document in different media.
Example
The following examples implement the @import rule −
HTML document −
<!DOCTYPE html> <html> <head> <style type="text/css"> @import url(style.css); body { background-color: honeydew; } </style> </head> <body> <p>This is demo paragraph one. </p> <p class="two">This is demo paragraph two.</p> <p>This is demo paragraph three</p> </body> </html>
CSS document: style.css
p { color: navy; font-style: italic; } .two { color: darkgreen; font-size: 24px; }
Output
This produces the following output −
Example
HTML document −
<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div></div> </body> </html>
CSS document−
div { height: 50px; width: 100px; border-radius: 20%; border: 2px solid blueviolet; box-shadow: 22px 12px 3px 3px lightblue; position: absolute; left: 30%; top: 20px; }
Output
This gives the following output −
- Related Articles
- Linking 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
- 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
- Importing Data in Python
- 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