Cascaded Style Sheets
Cascading Style Sheets (CSS) is a language designed for describing the appearance of
documents written in a markup language such as HTML.
With CSS we can control the color of text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background images or colors are used, and a variety of other visual effects. One of the major benefits is that the same CSS can be used by more than one page, meaning that the style of an entire website can be adjusted without having to change each page individually.
Advantages of Using CSS
- The presentation of an entire web site can be centralized to one or a handful of documents. CSS can be written independently of HTML.
- CSS separates a document's structure from its appearance.
- If a browser supports multiple alternative style sheets than more than one design of a web site can be presented at the same time.
- Style sheets allow content to be optimized for more than one type of device.
- Browser can cache the CSS file and reuse it.
- Users of a website can compose style sheets of their own, a feature that makes websites more accessible.
Cascade
A style sheet can originate from more than one source so it is necessary to establish an order of precedence to determine in which order style sheets apply styles for the page the user is seeing. It can come from a browser , from a user or from the author who wrote the web page. The precedence of each style sheet is as follows:
- The browser’s style sheet is the weakest.
- The user’s style sheet takes precedence over the browser’s style sheet.
- The author’s style sheet is the strongest and takes precedence over the user’s and the browser’s style sheets.
NOTE: The HTML style attribute can also be used to apply styles directly to an element, and these styles are more important than styles defined in any style sheet. Because style attributes will override styles in style sheets but it is not recommended.
Comments
Post a Comment