HTML CSS Styles
Styles in HTML
How to Use Styles
Styles Tags
Styles in HTML
With HTML 4.0 all formatting can be moved out of the HTML document and into a separate style sheet.
<html>
<head>
<style type="text/css">
h1{color:red}
h3{color:blue}
</style>
</head>
<body>
<h1>This is header 1</h1>
<h3>This is header 3</h3>
</body>
</html>
Nonunderlined Link
<html>
<body>
<a href="lastpage.htm" style="text-decoration:none">
THIS IS A LINK!
</a>
</body>
</html>
Link to an External Style Sheet
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>I am formatted with a linked style sheet</h1>
<p>Me too!</p>
</body>
</html>
How to use styles
When a beowser reads a style sheet, it formates the document according to the instructions in the sheet.
There are three types of style sheets: external,internal, and inline.
External Style Sheets
External style sheet is ideal when the style is applied to many pages.
With an external style sheet, you can change the look of an entire web site by changing one file.
Each page must link to the style sheet using the <link> tag.
The <link> tag goes inside the <head> section.
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Internal Style Sheet
An internal style sheet should be used when a single document has a unique style.
You define internal styles in the <head> section with the <style> tag.
<head>
<style type="text/css" >
body{background-color:gray}
p{margin-left:20px}
</style>
</head>
<p>The left margin is indented 20 pixels.</p>
Inline Styles
An inline style should be used when a style is to be applied to a single occurrence of an element.
To use inline styles, you use the style attribute in the relevant tag.
The style attribute can containe any CSS property.
<p style="color:red; margin-left:20px">
This is a paragraph. It's colored red and indented 20px.
</p>
Style Tags
TAG Description
<style> Defines a style definition
<link> Defines a resource reference
<div> Defines a section in a document
<span> Defines a section in a document
<font> Deprecated. Use styles instead
<basefont> Deprecated. Use styles instead
<center> Deprecated. Use styles instead
Styles in HTML
How to Use Styles
Styles Tags
Styles in HTML
With HTML 4.0 all formatting can be moved out of the HTML document and into a separate style sheet.
<html>
<head>
<style type="text/css">
h1{color:red}
h3{color:blue}
</style>
</head>
<body>
<h1>This is header 1</h1>
<h3>This is header 3</h3>
</body>
</html>
Nonunderlined Link
<html>
<body>
<a href="lastpage.htm" style="text-decoration:none">
THIS IS A LINK!
</a>
</body>
</html>
Link to an External Style Sheet
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>I am formatted with a linked style sheet</h1>
<p>Me too!</p>
</body>
</html>
How to use styles
When a beowser reads a style sheet, it formates the document according to the instructions in the sheet.
There are three types of style sheets: external,internal, and inline.
External Style Sheets
External style sheet is ideal when the style is applied to many pages.
With an external style sheet, you can change the look of an entire web site by changing one file.
Each page must link to the style sheet using the <link> tag.
The <link> tag goes inside the <head> section.
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Internal Style Sheet
An internal style sheet should be used when a single document has a unique style.
You define internal styles in the <head> section with the <style> tag.
<head>
<style type="text/css" >
body{background-color:gray}
p{margin-left:20px}
</style>
</head>
<p>The left margin is indented 20 pixels.</p>
Inline Styles
An inline style should be used when a style is to be applied to a single occurrence of an element.
To use inline styles, you use the style attribute in the relevant tag.
The style attribute can containe any CSS property.
<p style="color:red; margin-left:20px">
This is a paragraph. It's colored red and indented 20px.
</p>
Style Tags
TAG Description
<style> Defines a style definition
<link> Defines a resource reference
<div> Defines a section in a document
<span> Defines a section in a document
<font> Deprecated. Use styles instead
<basefont> Deprecated. Use styles instead
<center> Deprecated. Use styles instead
No comments:
Post a Comment