How CSS Inheritance Works

preview_player
Показать описание
Can you explain how CSS inheritance works?

CSS is cascading style sheets. CSS inheritance is when the CSS style selected sets values inherited by all the other properties.

So it flows down like variables that inherit properties from other variables.

Kind of, yeah. But when you look at the properties for the background on the webpage, the color doesn’t say “blue” but “inherited”.

That’s where the CSS style sheet determines all the details of the web page.

Not all of them, but many of them. The style sheet makes things easier by dictating the background color, font types, spacing and borders of all the pages so you don’t have to do it manually.

And the property inheritance is where it is all filled in automatically, instead of manually. If only the legal software we tried to use would be that easy.

No, lawyers won’t let you make it easy – they make sure the law is complex to ensure their continued employment.

It is interesting that IT developers did not do that.

Web developers pushed standards in IT and internet design to simplify their lives, to make websites and their interfaces as plug and play as their Ethernet cables.

So that’s where Cascading Style Sheets came from.

CSS is mandated by the HTML5 standard, which gets rid of Silverlight and Adobe Flash to play videos. It gets replaced by a video element.

That’s good if there is one less thing I can blame a website crash on, unless I’m the one who created it. What controls the elements, since I know they can change?

Cascading style sheets determines which properties can modify an element, the three being importance, specificity and source order. The style sheet gives each one of these weight and then modifies the style based on that.

I know the properties can be modified based on the type of device you’re on, reducing image sizes and increasing text sizes when it realizes you’re reading the page on a mobile device.

Not all properties get inherited. For example, background images are not inherited, though font and body elements are.

Yeah, you don’t need all the cute cat pictures showing up when reading the DCMA notice page.

Every element in the HTML document can inherit properties from the parent except for root. Root elements can’t inherit because they don’t have an orphan.

Root level everything is the odd one out in web design.

Then again, root level is all powerful, because it doesn’t have any parents telling it what to do.

What defines the importance of the style sheet element, aside from the “Oh, I love that shade of blue!”

Importance of an element’s settings can come from the browser’s default style sheet, user’s browser options and the CSS provided by the page.

You might think size 10 font is perfect on that page, but if I demand bigger text for readability, I get it.

And when the browser can’t handle the fancy settings, it can throw everything back to default HTML settings and ignore the cascading style sheet altogether.

Some people don’t have style.

Some people don’t want to have to see the style, like viewing things on ultra-slow connections or dealing with limited vision so turn off all the colors and distractions.

There are still over a million people or two using AOL from the 1990s.

At least with CSS, you can make sure that your website is visible to them and everyone else.
Рекомендации по теме