Without inheritance, it would be necessary to specify styles like font family, font size, and text color individually - for every single element type. Why inheritance is usefulĬSS has an inheritance mechanism because otherwise CSS rules would be redundant. For CSS3 properties, consult the individual CSS3 module specifications, available in the CSS current work page. In most cases, common sense indicates which properties are inherited and which are not: if you are not sure, look up all of the properties present in CSS2 in the CSS 2.1 specification property summary table. Imagine if you set the content block of a site to be 70% of the browser window width, and then all of its children adopted a width of 70% of their parent elements? Designing page layouts with CSS would be a nightmare. For instance, margins and width are not inherited, since it is unlikely that a child element requires the same margins as its parent. Not all CSS properties are inherited, because it does not make sense for some of them to be. Inheritance is the mechanism by which certain properties are passed on from a parent element down to its children, in the same fashion as genetics: if parents have blue eyes, their children will probably also have blue eyes. This article provides an overview of both concepts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |