Professional Documents
Culture Documents
Cascading Style Sheets, fondly referred to as CSS, is a simply designed language intended to simplify
the process of making web pages presentable. CSS allows to apply styles to web pages. It enables to
do this independent of the HTML that makes up each web page. It describes how a webpage should
look: it prescribes colors, fonts, spacing, and much more. In short, we can make our website look the
way we want. While html uses tags, css uses rulesets. CSS is easy to learn and understand, but it
provides powerful control over the presentation of an HTML document.
Advantages of CSS:
1. Size of HTML document decreases. So pages download faster.
2. HTML documents become neat. So, editing becomes easier.
3. Giving similar formatting parameter to similar contents becomes easier (As shown in
previous example, one set of property is effective on all <P> contents
4. Repetition of formatting property can be avoided. So, chances of mistakes are minimized.
5. Editing of formatting properties are easier and done at one place.
Few points about Style sheet:
1. In programming specification, it is a markup language.
2. Factually, it is document made up of plain text as HTML Document.
3. It is also created using a Text-Editing Application(e.g. Notepad)
4. It must be created with .CSS extension.(Hope you all remember how to give .CSS in filename)
CSS Syntax:
CSS comprises style rules that are interpreted by the browser and then applied to the corresponding
elements in your document. A style rule set consists of a selector and declaration block.
Selector is name of elements to format. Declaration is property and its value within curly bracket
separated by :. Multiple properties are separated by semicolon.
Ex- h1,p {color:blue; text-decoration:underline}
1. Inline Stylesheet(Used as attribute of tag): Applicable only on tag where style attribute is used.
2. Internal or Embedded Stylesheet (Used as Tag inside Head Tag) : Applicable to one or more
elements.
<Head>
<Style type=”text/css”>
P {color:green; text-decoration:underline} – Applicable to all P elements in document.
h1 {color:blue; text-decoration:underline} – Applicable to all H1 elements in document.
<Style>
</Head>
3. External Stylesheet.
Here, HTML document and stylesheet document are stored separately. Stylesheet document is also
a text file, created using text editor (notepad) and saved with .CSS extension. Using a LINK tag, the
stylesheet is linked to the HTML document.
**** HTML Document saved as CSSTEST.HTML
<HTML>
<Head>
<Title>My Page</Title>
<link rel="Stylesheet" href="mystyle.css" type="text/css">
</Head>
<Body>
<h1 >St. Michael’s High School, Digha Ghat, Patna - 1</h1>
<P >St. Michael’s High School, Digha Ghat, Patna - 1</P>
</body>
</HTML>
**** CSS Document saved as mystyle.css
P {color:green; text-decoration:underline}
h1 {color:blue; text-decoration:underline}
LINK – It is a HTML tag to link HTML document to other documents. Its attributes are
Rel – indicates type of relation between HTML and CSS document.
Type – Type of file to be related. For you, it is always text/css.
Properties and their values
Border Vs Outline
a. Outlines do not take up space, because they always placed on
top of the box of the element which may cause them to
overlap other elements on the page.
b. Unlike borders, outlines won't allow us to set each edge to a
different width, or set different colors and styles for each
edge. An outline is the same on all sides.
c. Outlines do not have any impact on surrounding elements
apart from overlapping.
d. Unlike borders, outlines do not change the size or position of
the element.
e. Outlines may be non-rectangular, but you cannot create
circular outlines.