A CSS (CASCADING STYLE SHEET) is a file separates the websites from the (X) HTML content's file.
The (X) HTML file arrange the contains but for presentation (Border, style, color, table etc).we use these CSS sheet.
We can use CSS sheet in two methods like INTERNAL and EXTERNAL style sheet.
1. INTERNAL STYLE SHEET:
In this we simply placing the CSS code in within the tags of each (X) HTML file.
The format is like:
In this method if we change for a single page are changes to all pages. This method can be used if we need style for one page.
2. EXTERNAL STYLE SHEET:
An external CSS file can be created with any text or HTML editor such as “Notepad” or “Dreamweaver”. A CSS file contains no (X) HTML, only CSS. We have to save it with the CSS file extension. You can link to the file externally by placing one of the following links in the head section of every (X) HTML file you want to style with the CSS file.
By using an external style sheet, you’re entire (X) HTML files link to one CSS file in order to style the pages. This means, that if you need to alter the design of all your pages, you only need to edit one CSS file to make global changes to your entire website.
Here are a few reasons this is better.
Easier Maintenance
Reduced File Size
Reduced Bandwidth
Improved Flexibility
We can write CSS code using respective syntax.
The syntax for CSS is different than that of (X) HTML markup. It consists of only 3 parts
Selector {property: value}
The selector is the (X) HTML element that you want to style. The property is the actual property title, and the value is the style you apply to that property.
Each selector can have multiple properties, and each property within that selector can have independent values. The property and value are separated with a colon and contained within curly brackets. Multiple properties are separated by a semi colon. Multiple values within a property are sperated by commas, and if an individual value contains more than one word you surround it with quotation marks. As shown below.
Body {
background: #eeeeee;
font-family: “Trebuchet MS”, Verdana, Arial, serif;
}
As you can see in the above code it from the color from the font-family with a semi-colon, separated the various fonts with commas and contained the “Trebuchet MS” within quotations marks. The final result sets the body color to light grey, and sets the font to ones that most users will have installed on there computer.
Combining Selectors
You can combine elements within one selector in the following fashion.
h1, h2, h3, h4, h5, h6 {
color: #009900;
font-family: Georgia, sans-serif;
}
In the above code its combine to all headings like h1 to h6 to one selector.Each one is separated by comma.
The final result of the above code sets all headers to green and to the specified font.
No comments:
Post a Comment