The third day of HTML learning--13th, 14 chapters

Source: Internet
Author: User
Tags border color

Color value abbreviation

The CSS style of the color is also abbreviated, and if you set the color to 16, you can abbreviate it by half if the values are the same for each of the two digits.

Example 1:

P{color: #000000;}

can be abbreviated as:

P{color: #000;}

Example 2:

P{color: #336699;}

can be abbreviated as:

P{color: #369;}




Font abbreviations

The font CSS style code in the Web page also has his own abbreviation, the following is the code to set the font for the page:

body{    font-style:italic;    Font-variant:small-caps;     Font-weight:bold;     font-size:12px;     line-height:1.5em;     font-family: "Song Body", Sans-serif;}

So many lines of code can actually be abbreviated as a sentence:

body{    font:italic  small-caps  bold  12px/1.5em  "song Body", Sans-serif;}

Attention:

1, use this shorthand method you must specify at least the Font-size and Font-family properties, other properties (such as Font-weight, Font-style, Font-varient, Line-height) will automatically use the default value if not specified.

2, in the abbreviation font-size and line-height the middle to join "/" oblique carry.

In general, because the Chinese site, the English is still relatively small, so the following abbreviation code is more commonly used:

body{    font:12px/1.5em  "song Body", Sans-serif;}

Only font size, line spacing, Chinese fonts, English fonts are set.

Color values

The color settings in a Web page are very important, with font color (color), background color (background-color), border color (border), and so on, there are many ways to set colors:

1, English command color

The Setup method is often used in the previous sections:

p{color:red;}

2. RGB Color

This is consistent with the RGB colors in Photoshop and is color-matched by the proportions of R (red), G (green), and B (blue) Three colors.

P{color:rgb (133,45,200);}

The value of each item can be an integer between 0~255, or it can be a percentage of 0%~100%. Such as:

P{color:rgb (20%,33%,25%);}

3. Hex Color

This color setting method is now more commonly used method, the principle is also RGB settings, but its value of each item from 0-255 to hexadecimal 00-ff.

P{color: #00ffff;}

Color table:

Length value

Length unit summary, at present more commonly used to px (pixels), EM,% percent, you should pay attention to the fact that these three units are relative units.

1, Pixel

Why are pixels relative units? Because pixels refer to dots on the display (the CSS specification assumes "90 pixels = 1 inches"). The reality is that the browser uses the actual pixel value of the display, and most designers now tend to use pixels (px) as units.

2, EM

is the font-size value of the given font for this element, 1em = 14px If the element's font-size is 14px, and 1em = 18px If the font-size is 18px. The following code:

P{font-size:12px;text-indent:2em;}

The code above is the ability to indent the first line of a paragraph by 24px (that is, the distance of two font sizes).

A special case is noted below:

However, when Font-size is set to EM, the criteria for this calculation are based on the font-size of the parent element of P. The following code:

Html:

<p> Take this <span> example </span> for example. </p>

Css:

P{font-size:14px}span{font-size:0.8em;}

As a result, the font "example" font size in span is 11.2px (0.8 = 11.2px).

3. Percentage

p{font-size:12px;line-height:130%}

Set the line height (line spacing) to the font's 130% (* 1.3 = 15.6px).

The third day of HTML learning--13th, 14 chapters

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.