Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there no difference between No media and media="all" in css link?

Tags:

html

css

Is there no difference between No media and media="all"?

<link rel="stylesheet" type="text/css" media="all" href="style.css">

and

<link rel="stylesheet" type="text/css" href="style.css">
like image 308
Jitendra Vyas Avatar asked Aug 03 '11 04:08

Jitendra Vyas


People also ask

What is media in CSS link?

The media attribute specifies what media/device the target resource is optimized for. This attribute is mostly used with CSS style sheets to specify different styles for different media types. The media attribute can accept several values.

What is difference between media and media screen?

@media is the actually media query. The word screen is adding the 'conditions' to the media query. So @media screen is telling the media query to apply (whatever other conditions) to screens. For example, @media screen and (max-width: 360px) will target only screens with a max-width of 360px.

How do I link media queries in CSS?

The Placement of Media Queries The internal method includes adding the <style> tag to the <head> tag of the HTML file, and creating the media query within the parameters of the <style> tag. The external method involves creating a media query in an external CSS file and linking it to your HTML file via the <link> tag.


2 Answers

In HTML 4.01, the default value is screen.
In HTML5, the default value has been changed to all.

Therefore, it depends on the doctype declaration you use in your page. Never mind, user agents get confused about standards anyway; see Knu's comment. (I bet this is why they changed it to all in HTML5.)

Then again, this only really matters if you're supporting user agents that don't present pages on digital screens, or display any visual information for that matter.

like image 71
BoltClock Avatar answered Sep 27 '22 22:09

BoltClock


Both yes and no it seems. In section 14.4.1 in the specs it says that a stylesheet without a media-type applies to all medias, whilst the other are filtered out when not needed. But in section 14.2.3 it should default to screen, which should be used on non-paged computer screens whilst all should be suitable for all devices (more information on media-descriptors here).

like image 35
Rickard Avatar answered Sep 27 '22 20:09

Rickard