¿Cómo especificar atributos de fuente para todos los elementos en una página web html?


Cuando establezco la familia de fuentes, el tamaño de fuente, el color, etc. parece que algunos elementos anidados anulan estos con los valores predeterminados del navegador feo.

¿Realmente debo especificar esas docenas de veces para cualquier tipo de elemento en mi página, o hay una manera de establecerlas globalmente de una vez y para siempre?

¿Cómo hacer eso?

 94
css
Author: Proud Member, 2010-10-15

5 answers

* {
 font-size: 100%;
 font-family: Arial;
}

El asterisco implica todos los elementos.

 188
Author: Bazzz,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-15 12:57:14

Si está utilizando IE, es probable que vuelva a los valores predeterminados del navegador para ciertos elementos, como las tablas. Puedes contrarrestarlo con algo como el siguiente CSS:

html, body, form, fieldset, table, tr, td, img {
    margin: 0;
    padding: 0;
    font: 100%/150% calibri,helvetica,sans-serif;
}

input, button, select, textarea, optgroup, option {
    font-family: inherit;
    font-size: inherit;
    font-style: inherit;
    font-weight: inherit;
}

/* rest of your styles; like: */
body {
    font-size: 0.875em;
}

Editar: es posible que desee leer sobre los resets CSS; ver hilos como este

 15
Author: Paul,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 11:54:44

No puedo enfatizar este consejo lo suficiente: use una hoja de estilos de reinicio, luego establezca todo explícitamente. Reducirá tu tiempo de desarrollo CSS entre navegadores a la mitad.

Prueba el reset de Eric Meyer .css.

 9
Author: Chris Cox,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-23 06:58:44

Puedes establecerlos en la etiqueta body

body
{
    font-size:xxx;
    font-family:yyyy;
}
 7
Author: jimplode,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-15 12:37:42

Si especifica atributos CSS para su elemento body debería aplicarse a cualquier cosa dentro de <body></body> siempre y cuando no los reemplace más adelante en la hoja de estilos.

 1
Author: Tyler Treat,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-15 12:37:23