8 Add some styles: Start learning CSS

Source: Internet
Author: User

The simple expression in CSS becomes the rule. A typical rule consists of a selector, several attributes, and a property value.

1. To add CSS styles directly in XHTML, you must add style start and end tags to the

<style type= "Text/css" >

.....

</style>

The Color property is used to change font colors. The Font-family property is used to format the font. The Border-bottom property is used to control the appearance of element underlines (such as border:1px solid black).

It is common to combine styles that are common between elements (if you want to change it, you only need to modify one rule), and the style that is specific to one element is written in another rule.

2. Another way to add CSS styles is to create a CSS file. CSS files are often called style sheets.

Use <link> to link XHTML to an external style sheet. The Rel property indicates the relationship between the XHTML file and the file to be linked, and the href is used to locate the file you want to link to (you can use a relative link or you can use a URL). <link> is an empty element.

<link type= "text/css" rel= "xx" href= "xx"/>

In CSS, the rules that are referenced are always the most specific. You can override a property from a parent node with a more specific selector.

In general, styles that affect the appearance of text, such as font color, font, and other font-related attributes (font size, font width, and so on) can be inherited. Other attributes, such as borders, are not inherited.

Using XHTML and CSS, you can define an element class and then provide a style to any element that belongs to that class.

If all element names are omitted, and a period is followed by a class name, then the rule will apply to all members within that class.

An element can be added to multiple classes. If the conflict cannot be resolved because the two selectors have the same specificity, you can resolve the conflict by using the rule sort in the style table. That is, use the rules in the CSS file that are most closely behind (closest to the bottom).

8 Add some styles: Start learning CSS

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.