CSS-Introduction
CSS-Introduction
Pages load faster − If you are using CSS, you do not need to write HTML tag
attributes every time. Just write one CSS rule of a tag and apply it to all the
occurrences of that tag. So less code means faster download times.
Easy maintenance − To make a global change, simply change the style, and
all elements in all the web pages will be updated automatically.
Superior styles to HTML − CSS has a much wider array of attributes than
HTML, so you can give a far better look to your HTML page in comparison to
HTML attributes.
Multiple Device Compatibility − Style sheets allow content to be
optimized for more than one type of device. By using the same HTML
document, different versions of a website can be presented for handheld
devices such as PDAs and cell phones or for printing.
Global web standards − Now HTML attributes are being deprecated and
it is being recommended to use CSS. So its a good idea to start using CSS in
all the HTML pages to make them compatible to future browsers.
Offline Browsing − CSS can store web applications locally with the help
of an offline catche.Using of this, we can view offline websites.The cache
also ensures faster loading and better overall performance of the website.
CSS3 was became a W3C recommendation in June 1999 and builds on older
versions CSS. it has divided into documentations is called as Modules and
here each module having new extension features defined in CSS2.
CSS SYNTAX
Selector − A selector is an HTML tag at which a style will be applied.
This could be any tag like <h1> or <table> etc.
Property - A property is a type of attribute of HTML tag. Put simply, all
the HTML attributes are converted into CSS properties. They could
be color, border etc.
Value - Values are assigned to properties. For example, color property
can have value either red or #F1F1F1 etc.
CSS - INCLUSION
External Style Sheet
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Internal Style Sheet
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
Inline style
<h1 style="color:blue;margin-left:30px;">This is a heading</h1>
CSS COLORS
Background
Color
You can set the background color for HTML elements: