Getting Started: Learning Web styles CSS Selectors, attributes, and values

Source: Internet
Author: User
css| Web page

HTML has tags, CSS has selectors. Selectors are named for styles inside and outside styles.

Each selector has attributes in {}, such as simple dots like color,font-weight or background-color.

The value is followed by a colon (not equal sign) and the semicolon separates the attribute.

Body {
Font-size:0.8em;
Color:navy;
}

The above means setting the Font-size font size and color font colors for the body selector.

So basically, when it works with HTML pages, the text color between the body tag (the entire window content) is navy the font size is 0.8ems.

Length and percentage

CSS has many attribute values to specify units, but some basic units are used on some properties, before this is worth the attribute under them.

EM, such as FONT-SIZE:2EM, gives the size of the font, so 2em is twice times the size of the actual font.

PX, such as font-size:12px, is a pixel pixel unit.

PT, such as FONT-SIZE:12PX, is a unit of points pounds.

% For example font-size:80% is a percentage

Other units include PCs (12-point Western Type), cm (cm), mm (mm) and in (inches)

When the value is zero, the unit is not needed, for example: border:0 meaning has no border.

Web pages are not static, absolute media. This means that internal energy is scaled and distorted, and users should be allowed to adjust their preferred ways, including font size and screen size.

Because of this, it is recommended to use "em" and "%" on the font-size (width and height), compared to the PX can not be in most browsers to change the size, so use less, you can use in the size of the border.



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.