How to Use
Three Ways to Insert CSS
There are three ways of inserting a style sheet:
-
External style sheet
-
Internal style sheet
-
Inline style
With an external style sheet, you can change the look of an entire website by changing just one file! Each page must include a reference to the external style sheet file inside the <link> element. The <link> element goes inside the head section:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
An internal style sheet may be used if one single page has a unique style.Internal styles are defined within the <style> element, inside the head section of an HTML page
<!DOCTYPE html>
<html>
<head>
<style type = "text/css" media = "all">
h1 {
color: red;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
An inline style may be used to apply a unique style for a single element.
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>