Beginner's view: Three ways to apply CSS in Web pages

Source: Internet
Author: User
Tags html tags
css| Beginners | Web page

First, in the In-line line

Inline styles are used to directly use the Style property in HTML tags

<p style= "color:red" >text</p>

Set paragraph text red.

But keep in mind that the final HTML should be independent and use the presentation document, so inline styles should be avoided anywhere.

Ii. interior of the Internal

Embedded interior styles used throughout the page inside the head tag, style tags surround styles.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<title>css example</title>
<style type= "Text/css" >
p {

color:red;
}

A
Color:blue;
}
</style>
...

All paragraph text is red, link blue.
Like inline styles, you should keep the HTML and CSS separate, so we have only the savior left.

Third, external

External styles are used throughout a variety of page sites. It's a standalone CSS file, like the following:

p {
color:red;
}
A
Color:blue;
}

If the above is saved as "webjx.css", the link in the HTML is like this:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<title>css example</title>
<link rel= "stylesheet" type= "Text/css" href= "Webjx.css"/>
...

The next tutorial will talk about other ways of outreach styles, and now it's enough.

From this tutorial, we will follow the above method of experimental code is a good idea, with a text editor to create a new file, save as "Webjx.css" in the HTML directory.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<title>my the Web page</title>
<link rel= "stylesheet" type= "Text/css" href= "Webjx.css"/>
...

Save HTML file, now linked to CSS, but now CSS is empty, no content will not change the HTML. When you start to learn CSS, you can add code to the CSS file to see the results of the HTML refresh.



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.