Welcome to Private Academy! Discover the latest in tech news, software, AI, engineering, and IT trends with our expert analysis and insightful articles.
About us
Get link
Facebook
X
Pinterest
Email
Other Apps
Welcome to Private Academy! Discover the latest in tech news, software, AI, engineering, and IT trends with our expert analysis and insightful articles.
Inheritance In CSS CSS, or Cascading Style Sheets, allows us to style web pages. But have you ever wondered how styling a parent element affects its child elements? That’s the concept of inheritance. First, let’s look at a simple example. Here’s an HTML file with a <div> element containing a few paragraphs. Now, let’s create a CSS file to style it. Like this: Here, we’ve given the .parent class a blue color and Arial font-family. Now, let’s see how these styles apply to the paragraphs. You can see that both paragraphs are blue and use the Arial font-family. This is the magic of inheritance! The color and font-family of the parent element are automatically inherited by the child elements. The benefit of inheritance is that you don’t have to repeatedly write the same properties. If you style the parent element, its effect is also visible on the child elements. Non Inherited Properties - However, not all properties are inherited. For example, margin , padding , and border propert...
Comments
Post a Comment