html - How to change css for an element but keep defaults for it's children -
i want set font-family div, want it's children keep default properties. possible?
you cannot, because if inner element not have value set particular property, inevitably inherit parent, if property defined “inherited: yes” in css specifications. is, in essence, idea of inheritance.
there not many situations authors want preserve default values properties, since defaults browser-dependent , unsuitable (e.g., common default font-family times new roman).
it possible meant else, preserving property values set elsewhere in style sheet. different issue, , answer happens automatically. if things don’t seem work way, reason misunderstanding of cascade. if have span element property set, value apply, no matter value set enclosing div element. span element not inherit property body element, example, except possibly indirectly (via div element).
assuming want preserve default values elements inside div element, here’s how things on small hands-on exercise page (for playing css). there’s div containing sample content, styled, , @ start, must appear unstyled (except external dimensions , border div). group other content on page inside containers specific class attribute. set all css settings page selectors contain class selector class. it’s bit clumsy, simple.
Comments
Post a Comment