There are four ways to associate styles with your HTML document. Most commonly used methods are inline CSS and External CSS.
- Inline Style
- Internal Style Sheet
- External Style Sheet
- Import Style Sheet
An external style sheet is ideal when the style is applied to many pages.
External style sheet include using <link> tag. The <link> tag goes inside the head section.
<head>
<link type=”text/css” rel=”stylesheet” href=”style.css” />
</head>
Internal Style Sheet:
An style sheet should be used when a single document has a unique style. Internal style sheet using inside head section.
Example:
<head>
<style type=”text/css”>
.paragraph{ color:red: text-align:center; }
</style>
</head>
Inline CSS
Inline Style use the style attribute in the revelant tag.
Example:
<h1 style=”color:blue; font-size:20px”>Hello world!</h1>
Imported CSS - @import Rule:
@import is used to import an external stylesheet in a manner similar to the <link> element. Here is the generic syntax of @import rule.<head> <@import "URL"; </head> |
<head> <@import url("URL");
</head> |
Example:
Following is the example showing you how to import a style sheet file into HTML document:<head> @import "mystyle.css"; </head> |

0 comments:
Post a Comment