Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct syntax for include css file?

Tags:

css

Depending on where I look, I see different way to include css.

Examples

<link rel="stylesheet" type="text/css" media="screen, projection" href=""/>
<link rel="stylesheet" type="text/css" media="all"                href=""/>
<link rel="stylesheet" type="text/css" media="screen"             href=""/>
<link rel="stylesheet"                                            href=""/>

Do they all do the same?

Is one of them the correct way?

like image 222
Sandra Schlichting Avatar asked Jun 16 '11 12:06

Sandra Schlichting


1 Answers

All are correct. The type attribute is not required - it is just a hint for browsers but can be omitted. The media attribute tells the browser when the CSS file should be used. For example, if you specify media="print" the CSS file will only get used when printing the page (try to print a Wikipedia page, for example).

Generally this variant is fine in most situations:

<link rel="stylesheet" type="text/css" href="..."/>
like image 126
Udo G Avatar answered Oct 02 '22 23:10

Udo G