Documente Academic
Documente Profesional
Documente Cultură
Information Technology II
Style Sheets:
Disadvantages
Larger Initial Time
Commitment
Advantages
More Precise Formatting
Separation of HTML
Content from Appearance
Saves Time
Easier Site Maintenance
Web Accessibility
The original HTML was never intended to contain tags for formatting a
document. HTML tags were intended to define the content of a document.
<font> & color attributes were just added to HTML 3.2 specification
W3C created CSS in addition to HTML 4.0
All browsers support CSS today.
Style Sheets:
CSS External style
An 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.
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
CSS Internal style
An internal style sheet should be used when a single document has a
unique style. It is seen inside the head tag.
<html>
<head>
<style type="text/css">
body {background-color: yellow}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
CSS Inline style
An inline style loses many of the advantages of style sheets by mixing
content with presentation. Use this method sparingly, such as when a style is to
be applied to a single occurrence of an element.
<html>
<head>
</head>
<body>
<h1 style="color:#FF0000>Hello World!</h1>
</body>
</html>
Browser default
External style sheet
Internal style sheet (in the head section)
Inline style (inside an HTML element)
PARTS OF A CSS:
CSS is made up of 3 parts
Selector
<html>
<head>
Property
<style type="text/css">
Value
body {background-color:
yellow}
</style>
</head>
Grouping of Selectors
You can group selectors. Separate each with a comma.
h1, h2, h3, h4, h5{
color: green
}
With Class or ID selectors you can define different styles to the same type of
html element.
p.dog {text-align:right}
p.cat {text-align:center}
Head of HTML
Body of HTML
Writing comments
Comments are used to explain your code, and may help you when you edit the
source code at a later date. A comment will be ignored by browsers. A CSS comment
begins with "/*", and ends with "*/", like this:
/*This is a comment*/
CSS Examples:
EX 1. Using Internal stylesyntax
<html>
<head>
<style type="text/css">
body {background-color: yellow}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>