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