Front--CSS Notes

Source: Internet
Author: User

CSS is all called Cascading style sheets (cascading style Sheets), which is primarily used to define the display style of HTML content within the browser, such as text size, color, font bold, and so on.

p{   font-size:12px;   color:red;   Font-weight:bold;}

One advantage of using CSS styles is that by defining a style, you can have a uniform font, font size, or color for text in different page locations.

CSS code syntax

CSS styles consist of selectors and declarations , and declarations are made up of attributes and values , as shown in:

selectors , also called selectors, indicate the elements in the Web page to which you want to apply a style rule, as in this case, the text in all segments (p) in the page will turn blue, while other elements, such as OL, will not be affected.

declaration: in English curly braces "{}" is the declaration, the attribute and the value are separated by the English colon ":". When there are more than one statement, the middle can be a semicolon ";" Delimited, as shown below

CSS Comment Code

Just like in HTML annotations, there are comment statements in CSS: used /*注释语句*/ to mark (use in HTML <!--注释语句--> ). Just like the following code:

From the form of CSS-style code insertion, the basic can be divided into the following 3 kinds: inline, embedded and external three kinds

inline CSS style , written directly in existing HTML tags

内联式CSS style sheet is to write CSS code directly in the existing HTML tags ( multiple CSS style code settings can be written together, separated by semicolons ), such as the following code:

<p style= "color:red;font-size:12px" > here the text is red. </p>

The embedded CSS style is the ability to write CSS style code between <style type= "text/css" ></style> tags. The following code is implemented to set the text in three <span> tags to red:

<style type= "Text/css" >span{color:red;} </style>

Embedded CSS styles must be written between <style></style>, and in general the embedded CSS style is written between

external CSS Styles (also known as outreach) is to write the CSS code in a separate external file, the CSS style file with " .css " as the extension, in

<link href= "Base.css" rel= "stylesheet" type= "Text/css"/>

Attention:

1. CSS style file names are named with meaningful English letters, such as MAIN.CSS.

2, rel= "stylesheet" type= "text/css" is fixed notation cannot be modified.

3, <link> label location is generally written in the

Front--CSS Notes

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.