Basic CSS usage in HTML

Source: Internet
Author: User

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

Related Article

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.