Css
Css
• Style sheets represent the World Wide Web consortium‟s effort to improve on the tag and
attribute based style of formatting.
• Style sheets provide a way of customizing whole pages all at once and in much richer
detail than the simple use of tags and attributes.
<style type=”text/css”>
selector{property:value;property:value;}
selector{property:value;property:value;}
</style>
.• Every line in <style> tag is called as a “Rule” and a style rule has two parts:
a. Selector.
b. Set of declarations.
• A selector is used to create a link between the rule and the HTML tag.
a. Property.
b. Value.
A property specifies additional information and value specifies property value. For
example:
.
<style type=”text/css”>
h1 {
color: orange;
text-align: center;
p{
font-size: 20px;
</style>
• If we add above code in the <head> element of web page , entire web page will be
. displayed in various styles given in style element.
• Style sheets are implemented with cascading style sheets specification.
• Conventionally styles are cascaded i.e., we don‟t have to use just a single set of
styles inside a document, but we can import as many styles as we like.
• There are three mechanisms by which we can apply styles to our HTML
documents:
.
• Inline style sheets mix content with presentation. To use inline styles we use style
<html>
<head>
<title>HTML Tables</table>
</head>
<body bgcolor=‟pink‟>
<center>
<tr>
<th style=”background-color:blue”>Mail-Sites</th>
<th style=”background-color:green”>Job-Sites</th>
</tr><tr>
<td style=”background-color:grey”>Gmail</td>
<td style=”background-color:aqua”>Naukri</td>
</tr><tr>
<td style=”background-color:yellow”>Yahoo</td>
<td style=”background-color:purple”>JobStreet</td>
</tr></table>
</center></body></html>
• ><tr>
.• <th style=”background-color:blue”>MailSites</th>
• <th style=”background-color:green”>JobSites</th>
• </tr><tr>
• <td style=”background-color:grey”>Gmail</td>
• <td style=”background-color:aqua”>Naukri</td>
.
Embedded Style sheets
• An embedded style sheet is used when a single document has a unique style.
• The styles defined using embedded style sheets are applied throughout the page
and we put the styles into one place
<html>
.
<head>
<title>Embedded Style sheets</title>
<style type=”text/css”>
body{background-color: pink;}
h1 {
color:orange;
text-align:center;
}
p{
font-family: "Times NewRoman";
font-size: 20px;
}</style>
</head>
.<body>
<h1>Embedded Style Sheets</h1><br>
<p>This is a paragraph
</body>
</html>
.
External Style Sheets:
• External style sheets are just that the style sheets are stored separately from our
web page.
• These are useful especially if we are setting the styles for an entire website.
• When we change the styles in external style sheet we change the styles of all
pages.
• We use “<link>”element to access the style sheet file defined into our web page.
h1 {
p{
}
extern.html------ Main Script
<html>
<head>
</head>
<body>
<p>This is a paragraph
</body>
</html>
.