Why is this effect happening to the property all?

Asked

Viewed 37 times

0

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
    
        html {
            color: red;
            background: blue;
            border: 1px solid white;
        }

        body {
            color: yellow;
            background: green;
            all: inherit;
        }

    </style>
</head>
<body>

<h1>Esse é um título</h1>
<p>Esse é um parágrafo</p>

</body>
</html>

inserir a descrição da imagem aqui

In the code example above the body inherits all values of the properties of html because the property all is defined as inherit.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
    
        html {
            color: red;
            background: blue;
            border: 1px solid white;
        }

        body {
            color: yellow;
            background: green;
            all: unset;
        }

    </style>
</head>
<body>

<h1>Esse é um título</h1>
<p>Esse é um parágrafo</p>

</body>
</html>

inserir a descrição da imagem aqui

But when the value of the property is changed all for unset the font of h1 and p is diminished because? in this case the all: unset is behaving like inherit and not initial, right? then it would be whatever put all: inherit or all: unset, but this effect of the slightly smaller source I’m not understanding, someone explains to me what is happening?

  • 1

    They’re the same size to me

  • For me too, it’s all the same size, should be your impression there

  • It’s not! really the sizes are different I’ll edit the answer and put a print.

  • "answer" question.

  • Cara tested in Chrome and Firefox, and there was no change in font size... Check if you’re not zooming in on the browser window, or if it’s not some other kind of accessibility setting etc

  • Thank you for your help, if the problem isn’t happening on your computer should be in mine, I’ve tried it in several ways but it’s still the same, but I’ll try harder, because I don’t like having unsolved problems in my brain.

Show 1 more comment

1 answer

1

Your words:

"In this case the all: unset is behaving like inherit and not initial, right?"

No, wrong! If it is initial the font color is black, this is the starting value, not the inherited value. If you inherit he inherits the color of html however... That yes, would be almost the same thing as the unset

Once you put it all:unset in the body, he automatically inherits descending styles from html, for the body is the son of html

inserir a descrição da imagem aqui

In this other answer you have further clarification on the all All property in CSS. What it’s for and how it works?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.