![]() |
VOOZH | about |
CSS property can be include in the HTML page in a number of different ways. HTML documents are formatted according to the information in the style sheet which is to be included.
There are many ways to include CSS file which are listed below:
<link rel="stylesheet" href="style.css">
<style> @import url(style.css); </style>
<style>
element {
// CSS property
}
</style><h1 style="style property">Geeksforgeeks</h1>
Best Approach: The External Style Sheet (using HTML <link> Tag) is the best method which is used to link the element. Maintaining and re-using the CSS file across different pages is easy and efficient. The <link> tag is placed in the HTML <head> element. To specify a media type="text/css" for a Cascading Style Sheet <type> attribute which is used to ignore style sheet types that are not supported in a browser.
Example 1: The file given below contains CSS property. This file save with .css extension. For Ex: geeks.css
body {
background-color:powderblue;
}
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
#geeks {
font-style:bold;
font-size:20px;
}
Output:
👁 external css
Example 2: This example describes the Internal or Embedded CSS.
Output:
Example 3: This example describes the inline CSS.
Output:
@import rule: The @import rule is used to import one style sheet into another style sheet. This rule also support media queries so that the user can import the media-dependent style sheet. The @import rule must be declared at the top of the document after any @charset declaration.
Characteristics of @import:
Syntax:
@import url|string list-of-mediaqueries;
Property values:
Example 1: Consider the two CSS files as shown below.
@import url("i1css.css");
h1 {
color: #00ff00;
}h1 {
text-decoration: underline;
font-size:60px;
}
p {
padding-left: 20px;
font-size: 60px;
}
Output:
Example 2:
Output:
Supported Browser: