Media=All vs Media=Screen

2020-02-04 06:58发布

问题:

It seems like recently I have seen many more people starting to use media="all" vs media="screen" in their stylesheets.

My question is when should I use media="all" over media="screen" and vice versa?

Note: I am using HTML5 Doctype if that makes a difference.

回答1:

media="all"    // Used for all media type devices ( its default under html 5)
media="screen" // Used for computer screens(default value  for html 4.01)

Good read

7.3 Recognized media types
Is there no difference between No media and media=“all” in css link?



回答2:

According to W3C Spec:

7.3 Recognized media types

The names chosen for CSS media types reflect target devices for which the relevant properties make sense. In the following list of CSS media types the names of media types are normative, but the descriptions are informative. Likewise, the "Media" field in the description of each property is informative.

all

Suitable for all devices.

braille

Intended for braille tactile feedback devices.

embossed

Intended for paged braille printers.

handheld

Intended for handheld devices (typically small screen, limited bandwidth).

print

Intended for paged material and for documents viewed on screen in print preview mode. Please consult the section on paged media for information about formatting issues that are specific to paged media.

projection

Intended for projected presentations, for example projectors. Please consult the section on paged media for information about formatting issues that are specific to paged media.

screen

Intended primarily for color computer screens.

speech

Intended for speech synthesizers. Note: CSS2 had a similar media type called 'aural' for this purpose. See the appendix on aural style sheets for details.

tty

Intended for media using a fixed-pitch character grid (such as teletypes, terminals, or portable devices with limited display capabilities). Authors should not use pixel units with the "tty" media type.

tv

Intended for television-type devices (low resolution, color, limited-scrollability screens, sound available).