Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/08/2007, 04:18
Avatar de PatomaS
PatomaS
Colaborador
 
Fecha de Ingreso: marzo-2004
Ubicación: En alguna otra parte
Mensajes: 4.656
Antigüedad: 20 años, 1 mes
Puntos: 63
Información ¿Has usado el atributo style?. Lo has hecho mal

Hola

Bueno, no importa cuanto crea uno saber, definitivamente siempre hay cosas que considerar y cosas que aprender.

Hoy revisando algo de información para un escrito que estoy haciendo, me encontré con una de esas oscuras frases que alguna vez leí pero la costumbre, la vagancia o la falta de atención me hicieron pasar por alto. Al igual que a toda la gente conozco y que no conozco. Debo decir que aun no he visto un ejemplo real de lo que acabo de leer.

Aquí tienen la sección en español y aquí la definición original desde el W3C.

Para quienes les de fastidio ir a leer las referencias, les pongo abajo la parte importante:

Cita:
Authors should use the META element to set the default style sheet language for a document. For example, to set the default to CSS, authors should put the following declaration in the HEAD of their documents:
<META http-equiv="Content-Style-Type" content="text/css">
[...]
User agents should determine the default style sheet language for a document according to the following steps (highest to lowest priority):

1. If any META declarations specify the "Content-Style-Type", the last one in the character stream determines the default style sheet language.
2. Otherwise, if any HTTP headers specify the "Content-Style-Type", the last one in the character stream determines the default style sheet language.
3. Otherwise, the default style sheet language is "text/css".

Documents that include elements that set the style attribute but which don't define a default style sheet language are incorrect. Authoring tools should generate default style sheet language information (typically a META declaration) so that user agents do not have to rely on a default of "text/css".
Qué no dice todo esto, bueno, varias cosas, pero básicamente no dice que todos los que hemos hecho lo siguiente, lo hemos hecho mal.
Código HTML:
<p style="border:1px solid #f00;">bla bla bla</p> 
Debería haber sido hecho así:
Código HTML:
<head>
	<meta http-equiv="Content-Style-Type" content="text/css" />
...
</head>
...
<p style="border:1px solid #f00;" type="text/css">bla bla bla</p> 
A lo anterior, agregaré que ninguno de los editores visuales que he usado alguna vez han incluido dicha etiqueta meta. Hace mucho que no uso ninguno de ellos, pero estoy casi seguro de que no incluyen esa línea por defecto.

Es curioso que el mismo validador del W3C no indica nunca este error, especialmente cuando esta es una de las pocas ocasiones en que la definición es totalmente clara y concisa, sin lugar a interpretaciones ni errores de lectura.

Así que ya saben, si van a usar el atributo style en alguna etiqueta y quieren poder decir que su página no tiene errores, deben usar la etiqueta meta mencionada.

Felicidad
__________________
¡ hey, hou, hou, hey !