![]() | Cascading Style Sheets (CSS) |
About CSSCSS is created and maintained through a group of people within the W3C called the CSS Working Group. The CSS Working Group creates documents called specifications. When a specification has been discussed and officially ratified by the W3C members, it becomes a recommendation. These ratified specifications are called recommendations because the W3C has no control over the actual implementation of the language. Independent companies and organizations create that software. NOTE: The World Wide Web Consortium or W3C is a group that makes recommendations about how the Internet works and how it should evolve. Cascading Style Sheets level 1 (CSS1) came out of W3C as a recommendation in December 1996. This version describes the CSS language as well as a simple visual formatting model for all the HTML tags. CSS2 became a W3C recommendation in May 1998 and builds on CSS1. This version adds support for media-specific style sheets e.g. printers and aural devices, downloadable fonts, element positioning and tables. A CSS comprises of style rules that are interpreted by the browser and then applied to the corresponding elements in your document. A style rule is made of three parts:
Example table{ border :1px solid #C00; } Here table is a selector and border is a property and the given value 1px solid #C00 is the value of that property. Table Options border-collapse: collapse; /* Table Border line Traced */ SelectorsThe Universal SelectorsRather than selecting elements of a specific type, the universal selector quite simply matches the name of any element type: * { color: #000000; } This rule renders the content of every element in our document in black.The Descendant SelectorsSuppose you want to apply a style rule to a particular element only when it lies inside a particular element. As given in the following example, the style rule will apply to <em> element only when it lies inside the <ul> tag. ul em { color: #000000; }The Class SelectorsYou can define style rules based on the class attribute of the elements. All the elements having that class will be formatted according to the defined rule.
.black {
color: #000000;
}
This rule renders the content in black for every element with class attribute set to black in our document. You can make it a bit more particular. For example:
h1.black {
color: #000000;
}
This rule renders the content in black for only < h1 > elements with class attribute set to black.
You can apply more than one class selectors to a given element. Consider the following example:
This para will be styled by the classes center and bold. h1 { font-family: "Arial Narrow", Arial, sans-serif; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 700; line-height: 26.4px; } h3 { font-family: "Arial Narrow", Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 700; line-height: 15.4px; } p { font-family: "Arial Narrow", Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 20px; } blockquote { font-family: "Arial Narrow", Arial, sans-serif; font-size: 21px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 30px; } pre { font-family: "Arial Narrow", Arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 18.5714px; } /* This text is in Arial Narrow */
.class {
font-family: Arial Narrow,Arial,sans-serif;
}
|