Why do fields not inherit font styles from their parent elements in all browsers?

Patricia Arquette
Release: 2024-10-27 06:31:29
Original
958 people have browsed it

Why do <input> fields not inherit font styles from their parent elements in all browsers? 
fields not inherit font styles from their parent elements in all browsers? " />

Font Inheritance Issue in Fields

In an HTML document, certain elements may not inherit the font style defined for their parent element. This can be observed for fields, as illustrated in a specific example:

<label class="adm" for="UserName">User name</label><br><input class="adm" id="UserName" name="UserName" size="30" type="text" value="" />

If CSS is applied to inherit the font family from the element to these form elements:

body,html { font-family: Verdana,Arial,Helvetica,sans-serif; margin:0; padding:0; color: #111;}<br>label.adm  { font-size:0.9em; margin:0 0 3px 3px; display: block;}<br>input.adm  { font-size:0.9em; margin:0 0 3px 3px; }

Firefox renders these elements with different fonts. While the

This discrepancy arises because the element does not inherit the font family by default in all browsers. To explicitly force inheritance, CSS can be used:

input, select, textarea, button{font-family:inherit;}<br>

By incorporating this rule, the field will inherit the font family from its parent element, ensuring consistency in font style. A live demonstration of this solution can be found at http://jsfiddle.net/gaby/pEedc/1/.

The above is the detailed content of Why do fields not inherit font styles from their parent elements in all browsers?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!