Classification of Style sheets

Source: Internet
Author: User

CSS refers to cascading style sheets: Cascading style Sheets

Style defines how HTML elements are displayed. Style sheets allow style information to be specified in several ways. Styles can be specified in a single HTML element, in the header element of an HTML page, or in an external CSS file. You can even reference multiple external style sheets within the same HTML document.

In general, style sheets have the following four categories:

1) Browser default settings

2) External style sheet

3) Internal style sheet (inside

4) inline style (inside HTML elements)

When the same HTML element or attribute is defined by more than one style (style selector), the inline style has the highest precedence, and the browser default setting has the lowest precedence.

External style sheet CSS:

External style sheets are usually stored in CSS files to solve the problem of how content and performance are separated. By simply editing a simple CSS document, an external style sheet gives you the ability to change the layout and appearance of all the HTML pages in your site at the same time. CSS can be called a breakthrough in WEB design because it allows you to control the style and layout of multiple pages at the same time. As a web developer, you can define a style for each HTML element and apply it to as many pages as you want. To make a global update, simply change the style, and all elements in the site are automatically updated.

A CSS rule consists of two main parts: a selector and one or more declarations. The selector selector is an HTML element that you need to change the style of, each declaration consists of an attribute property and a corresponding value, the values. Attributes and values are separated by colons.

For example, the following line of CSS code defines the text color in the H1 element as red, and the font size to 14 pixels.

{color:red; font-size:14px;}

If you want to define more than one declaration, you need to separate each declaration with a semicolon. For example:

{      text-align: Center;       color: black;       font-family: Arial;    }

Selectors can also be grouped so that the grouped selectors can share the same declaration. Group the selectors with commas. For example:

{      color: green;      }

Internal style sheet:

When a single HTML document requires a special style, you should use an internal style sheet. Internal style sheets are defined in the header of the HTML document using <style> tags. For example:

<Head><styletype= "Text/css">HR{Color:Sienna;}P{Margin-left:20px;}Body{Background-image:URL ("images/back40.gif");}</style></Head>

Inline style:

Because of the mix of performance and content, inline styles lose many of the benefits of stylesheets. You need to use the Style property in the associated HTML tags to use inline styles. The Style property can contain any CSS properties. For example:

<style= "Color:sienna; margin-left:20px">This isa paragraph  </p>

Tips: Subsequent updates on how CSS defines a derived selector, an ID selector, a class selector, and a property selector.

Classification of Style sheets

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.