how to use inherit and initial properties in css?

Asked

Viewed 258 times

1

My CSS studies have resulted in finding the following properties: inherit and initial. The two at first seemed quite similar to me, but I really wanted to know is:

Where I can use inherit and initial?

In what situations I should not use inherit and initial?

Initially I found the terms similar, but it would be good to explain the difference between the two.

  • Read this article: https://tableless.com.br/understandndo-os-valores-initial-e-inherit-do-css/

1 answer

2


Basically the initial returns the initial value of the browser, so depending on the browser you use it can return a different value.

The inherit checks the value of the parent element, for example:

div{
color:red;
}
h1{
color:inherit;
}
<div>
    <h1>teste</h1>
</div>

If you put the H1 with the value initial it will change the color to black, which is the default browser.

Browser other questions tagged

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