How can I use CSS in HTML?

Source: Internet
Author: User
Tags html header

1. Add it directly to the HTML identifier (TAG)

<Tag style = "properties"> webpage content </Tag>
For example:
<P Style = "font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 9px; color: # ff9900"> CSS </P>

This method is simple and easy to use, but is not recommended. This method cannot show the advantages of style sheets: shorten the modification time and increase the workload.

2. Add it to the HTML header information identifier

Example

<HTML>
<Head>
<Title> page title </title>
<Style>
<! --
H2 {
Font-family: Child circle;
Color: red;
}
-->
</Style>
</Head>
<Body>
<H2> CSS markup </H2>
<P> CSS-marked body content 1 </P>
</Body>
</Html>

3. The link style sheet is also added to the HTML header information identifier

<Head>
<LINK rel = "stylesheet" href?”main.css "type =" text/CSS ">
</Head>

Mian.css (named by yourself) is a individually saved style sheet file, which cannot contain <style> identifiers and can only be suffixed with CSS. If you use a web site, we recommend that you use the connected style sheet

To modify the web site page, you only need to modify several CSS files to update the entire web page, shorten the modification time and increase the workload.

4.@ Import

<Style type = "text/CSS" Media = "screen">
@ Import "all.css ";
</Style>

The difference between link and @ import: the service object is different. @ import serves CSS, and link serves the current page. @ import takes precedence.

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.