Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/02/2013, 02:51
Gothgauss
 
Fecha de Ingreso: marzo-2009
Mensajes: 395
Antigüedad: 15 años, 1 mes
Puntos: 11
Meter css segun resolucion y que valide en W3C

Buenos días

Quiero que una web se centre verticalmente si la resolución de pantalla es mayor de 1024, por lo que en el head he incluido el siguiente código:
Código HTML:
<head>

<script type="text/javascript">

if(screen.width > 1024){
document.writeln("<link href='../../css/es/1152.css' rel='stylesheet' type='text/css' media='screen' />");

}
</script>
</head> 
Pero al pasar el validador W3C me dice que hay un error:

Código:
document type does not allow element "link" here
…f='../../css/es/1152.css' rel='stylesheet' type='text/css' media='screen' />");
✉
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
Que viene a decir que el código lo está metiendo en el body y no en el head.

Como haríais vosotros para que cogiera el css en función de la resolución sin usar CSS3 (porque el explorer 8 no lo soporta )