This article lists the basic methods for using CSS in HTML for your reference.
Reference a CSS file
[Css]
<Link type = "text/css" rel = "stylesheet" href = "js_css/menutree.css">
<Head> in HTML
[Css]
<Style type = "text/css">
</Style>
Use id
[Css]
<Style type = "text/css">
# LoginTable
{
}
</Style>
HTML
<Table id = "loginTable">
</Table>
Overwrite HTML Tag class
[Css]
<Style type = "text/css">
Table
{
}
</Style>
HTML
<Table>
</Table>
In this example, all the <table> labels on the page are uniformly defined.
Inherit the HTML Tag subclass
[Css]
CSS
<Style type = "text/css">
Table. login
{
}
</Style>
HTML
<Table class = "login">
</Table>
In this example, all <table> labels with the class = "login" attribute in HTML are uniformly defined.
Inherit pseudo State
[Css]
A: link {}
A: visited {}
A: active {}
A: hover {}
Again
A. menu: link {}
A. menu: visited {}
Custom class
A custom class starts with a period.
[Css]
<Style type = "text/css">
. LoginTable
{
}
</Style>
HTML
<Table class = "loginTable">
</Table>
In this example, all the labels of the specified class = "loginTable" are uniformly defined. Note that the attributes of various Html tags may be slightly different, that is, some of. loginTable attributes may not take effect. For example, specifying the float attribute for a table label does not take effect.
Define directly
HTML
[Css]
<Table style = "{border-width: 1px; border-style: solid;}">
</Table>
CSS and HTML Integration
CSS overwrites the HTML attribute definition.
CSS
[Css]
Table. s
{
Width: 100px;
}
HTML
<Table width = "400" height = "400" class = "s"> </table>
Because width is specified in CSS, the actual width is subject to CSS, width = 100; the height is not defined in CSS, And the HTML attribute prevails, height = 400
Author: iamshaofa