Sie sind auf Seite 1von 10

Presentation

on
Cascading Style Sheets
by
Sayandeb Pal
Introduction
• CSS is used by both the authors and readers of web pages
to define colors, fonts, layout, and other aspects of
document presentation. It is designed primarily to enable
the separation of document content (written in HTML /
XHTML / XML) from document presentation (written in
CSS) to improve content accessibility, provide more
flexibility and control in the specification of presentational
characteristics, and reduce complexity and repetition in the
structural content.

• The term cascading derives from the fact that multiple style
sheets can be applied to the same Web page.
Types of CSS
• Author styles (style information provided by the web page author)
– external stylesheets, i.e. a separate CSS-file referenced from the
document
– embedded style, blocks of CSS information inside the HTML
document itself
– inline styles, inside the HTML document, style information on a
single element, specified using the "style" attribute.

• User style
– a local CSS-file specified by the user using options in the web
browser, and acting as an override, to be applied to all
documents.

• User agent style


– the default style sheet applied by the user agent, e.g. the
browser's default presentation of elements.
External Style Sheets

• An external style sheet is ideal when the style is applied


to many pages.

• The file should not contain any html tags.

• The style sheet should be saved with a .css extension,


for example style.css
• Example of external style sheet file style.css:

hr {color: sienna}
p {margin-left: 20px}
body {background-image: url("images/back40.gif")}

• The <link> tag for the HTML pages :

<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
Embedded Style Sheets
• An embedded style sheet should be used when a single
document has a unique style.

• Example of embedded style sheet :

<head>
<style type="text/css">
body { background: #fff; color: #000; }
h1, h2 { font-style: italic; font-weight: bold; color: blue; }
</style>
</head>
Inline Style Sheets

• Inline style sheets are used when a style is to be applied to a


single occurrence of an element.

• Example of inline style sheet :

<h1 style="color: red; font-style: italic">


This is a header
</h1>
Advantages of CSS

• Presentation information for an entire website or collection of


pages can be held in one place, and can be updated quickly
and easily.

• Different users can have different style sheets.

• The document code is reduced in size and complexity.


Adaptation Limitation

• Microsoft Internet Explorer, version 6 lacks support for about


30 percent of CSS2 properties.

• Misinterpretation of a number of important properties, such as


"width", "height", and "float".
Thank You

Das könnte Ihnen auch gefallen