search

css value

Feb 15, 2017 pm 01:12 PM

Source of CSS values

First of all, we know that although CSS has simple syntax, it is not written blindly. Its properties and values ​​are officially defined, to be precise, they are defined by the browser manufacturer. of.

These given values ​​​​are nothing more than the following sources:

  1. inherit means inheriting the value from the ancestor element. Every attribute has it.

  2. initial represents the default value of the user agent. Every attribute has it.

  3. Browser-specific values ​​usually have prefixes such as -ms-, -webkit-, etc., and some values ​​have no prefix.

  4. Values ​​shared by browsers. Although they are shared, the implementation of each browser is not necessarily the same.

Therefore, it is certain that css compatibility issues are mostly caused by the inconsistency and evolution of css rendering implemented by browser manufacturers.

Values ​​in CSS specifications

The value finally presented to the user goes through 4 steps: first the specified value (the "specified value"), and then the inherited value (the " computed value"), then converted into the used value (the "used value"), and finally the actual value (the "actual value") obtained due to the limitations of the browser itself.

That is, specifies Value-->Calculated value-->Used value-->Actual value

Specified value

There are three possibilities for specifying the value. One is the default value of the user agent. That is, initial, one is the value written by the artist in the program, and the other is the value that is explicitly specified for inheritance, that is, inherit.

Normally, neither inherit nor initial need to be explicitly specified. But in some cases these 2 values ​​are very useful.

computed value

This is the value calculated by the rendering engine through parsing the CSS file and the inheritance relationship of the cascading rules before the document is formed.

used value

This is the value obtained after css is combined with html to form a document.

Understand that the difference between calculated values ​​and used values ​​is that the browser first parses the HTML and CSS files separately, and then merges them. Please refer to these 2 pictures for details.

webkit rendering process
css值

Geoko rendering process
css值

actual value

is the last browser available For example, all browsers cannot handle 7 decimal places, so the precision will be reduced.

These 4 values ​​​​are derived from the specification. Other browser implementations may not work according to this 4-step process, but currently mainstream browsers follow this process.

Note that the cascade is different In inheritance. Cascading is for individual CSS properties, inheritance is for elements. Layering often comes with weighting issues.

Chrome Developer

css值

  1. Specify value (3 types)

  2. User agent default value (cannot be changed)

  3. The value with an underscore indicates that it is overridden by the cascading rule, that is, the style is overwritten by the weighted one.

  4. Click 4 to jump to the corresponding node and style view. The part below 4 indicates which element the style is inherited from. Usually you can see the ancestor DOM chain of the element from here.·

  5. ##The gray part

    can be changed, Indicates that the rule is not available and is evaluated at runtime.

Example:

I now specify the height of h1 as follows

css值

Look at the computed value and you can see that chrome retains it 4 digits after the decimal point:

css值

View the used value (the reason for looking in this box is that the box represents the formation of a document, which corresponds to the previous used value)

css值

The final actual value is here (view it directly on the page):

css值

You can see that if there is padding, the padding will form the document Then add it to the visual width and height when displayed on the browser. Of course, it is different if the box-sizing attribute is specified, but you can know that this happens in the last step.

Source of CSS values

First of all, we know that although CSS has simple syntax, it is not written blindly. Its attributes and values ​​are Officially defined, to be precise, defined by the browser manufacturer.

These given values ​​​​are nothing more than the following sources:

  1. inherit means inheriting the value from the ancestor element. Every attribute has it.

  2. initial represents the default value of the user agent. Every attribute has it.

  3. Browser-specific values ​​usually have prefixes such as -ms-, -webkit-, etc., and some values ​​have no prefix.

  4. Values ​​shared by browsers. Although they are shared, the implementation of each browser is not necessarily the same.

Therefore, it is certain that css compatibility issues are mostly caused by the inconsistency and evolution of css rendering implemented by browser manufacturers.

Values ​​in CSS specifications

The value finally presented to the user goes through 4 steps: first the specified value (the "specified value"), and then the inherited value (the " computed value"), then converted into the used value (the "used value"), and finally the actual value (the "actual value") obtained due to the limitations of the browser itself.

That is, specifies Value-->Calculated value-->Used value-->Actual value

Specified value

There are three possibilities for specifying the value. One is the default value of the user agent. That is, initial, one is the value written by the artist in the program, and the other is the value that is explicitly specified for inheritance, that is, inherit.

Normally, neither inherit nor initial need to be explicitly specified. But in some cases these 2 values ​​are very useful.

computed value

This is the value calculated by the rendering engine through parsing the CSS file and the inheritance relationship of the cascading rules before the document is formed.

used value

This is the value obtained after css is combined with html to form a document.

Understand that the difference between calculated values ​​and used values ​​is that the browser first parses the HTML and CSS files separately, and then merges them. Please refer to these 2 pictures for details.

webkit rendering process
css值

Geoko rendering process
css值

actual value

is the last browser available For example, all browsers cannot handle 7 decimal places, so the precision will be reduced.

These 4 values ​​​​are derived from the specification. Other browser implementations may not work according to this 4-step process, but currently mainstream browsers follow this process.

Note that the cascade is different In inheritance. Cascading is for individual CSS properties, inheritance is for elements. Layering often comes with weighting issues.

Chrome Developer

css值

  1. Specify value (3 types)

  2. User agent default value (cannot be changed)

  3. The value with an underscore indicates that it is overridden by the cascading rule, that is, the style is overwritten by the weighted one.

  4. Click 4 to jump to the corresponding node and style view. The part below 4 indicates which element the style is inherited from. Usually you can see the ancestor DOM chain of the element from here.·

  5. ##The gray part

    can be changed, Indicates that the rule is not available and is evaluated at runtime.

Example:

I now specify the height of h1 as follows

css值

Look at the computed value and you can see that chrome retains it 4 digits after the decimal point:

css值

View the used value (the reason for looking in this box is that the box represents the formation of a document, which corresponds to the previous used value)

css值

The final actual value is here (view it directly on the page):

css值

You can see that if there is padding, the padding will form the document Then add it to the visual width and height when displayed on the browser. Of course, it is different if the box-sizing attribute is specified, but you can know that this happens in the last step.

For more css value related articles, please pay attention to the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is CSS Grid?What is CSS Grid?Apr 30, 2025 pm 03:21 PM

CSS Grid is a powerful tool for creating complex, responsive web layouts. It simplifies design, improves accessibility, and offers more control than older methods.

What is CSS flexbox?What is CSS flexbox?Apr 30, 2025 pm 03:20 PM

Article discusses CSS Flexbox, a layout method for efficient alignment and distribution of space in responsive designs. It explains Flexbox usage, compares it with CSS Grid, and details browser support.

How can we make our website responsive using CSS?How can we make our website responsive using CSS?Apr 30, 2025 pm 03:19 PM

The article discusses techniques for creating responsive websites using CSS, including viewport meta tags, flexible grids, fluid media, media queries, and relative units. It also covers using CSS Grid and Flexbox together and recommends CSS framework

What does the CSS box-sizing property do?What does the CSS box-sizing property do?Apr 30, 2025 pm 03:18 PM

The article discusses the CSS box-sizing property, which controls how element dimensions are calculated. It explains values like content-box, border-box, and padding-box, and their impact on layout design and form alignment.

How can we animate using CSS?How can we animate using CSS?Apr 30, 2025 pm 03:17 PM

Article discusses creating animations using CSS, key properties, and combining with JavaScript. Main issue is browser compatibility.

Can we add 3D transformations to our project using CSS?Can we add 3D transformations to our project using CSS?Apr 30, 2025 pm 03:16 PM

Article discusses using CSS for 3D transformations, key properties, browser compatibility, and performance considerations for web projects.(Character count: 159)

How can we add gradients in CSS?How can we add gradients in CSS?Apr 30, 2025 pm 03:15 PM

The article discusses using CSS gradients (linear, radial, repeating) to enhance website visuals, adding depth, focus, and modern aesthetics.

What are pseudo-elements in CSS?What are pseudo-elements in CSS?Apr 30, 2025 pm 03:14 PM

Article discusses pseudo-elements in CSS, their use in enhancing HTML styling, and differences from pseudo-classes. Provides practical examples.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool