w3-video.com logo

HTML5 Tutorial

Home HTML5 XAMPP .htaccess Firefox Notepad++

Share it



link media attribute

The media attribute on the link element:

Examples

<linkattribute="value(s)" >Examples
3.media=all, braille, embossed, handheld
print, projection, screen, speech
tty, tv
<link rel="stylesheet" href="print.css" media="print">

Video demonstration link media attribute

HTML5 link media attribute Tutorial

min video details
00:14 this video tutorial presents the media attribute and 3 of its values: all, screen, print on a link element;

note: the rest of the attributes cannot be demonstrated with the present tools
00:22 if media attribute is omitted or its value is all → the linked resource applied to all media
00:26 A) media attribute is omitted
00:26 when media attribute is omitted, the linked resource applies to all media
00:33 tests:
on screen: ok, the linked resource, main.css, applied
on print preview: ok, main.css applied
00:42 B) media attribute has the value: all
00:47 when media attribute has the value all, the linked resource 'main.css' applied to all media
00:53 tests:
on screen: ok, main.css applied
on print preview: ok, main.css applied
01:03 in both media, screen, print , the page looks the same because the linked resource, main.css, applied in both cases
01:18 C) media attribute has the value: screen
01:20 when the media attribute has the value: screen, then the linked resource, main.css, applies to screen media only
01:24 tests:
on screen: ok, main.css applied
on print preview: ok, main.css DID NOT apply
01:34 D) media attribute has the value: print
01:37 when the media attribute has the value: print, then the linked resource, main.css, applies to print media only
01:42 tests:
on screen: ok, main.css DID NOT apply
on print preview: ok, main.css applied
01:55
With media attribute you can specify different styles for different media:

main.css applies on screen, while
print.css applies on print
02:03 tests:
main.css applied on screen: ok
print.css applied on print preview: ok
02:36 different display of the same page in 2 different media;
the font size, the font-family and the background are different
link intro link optional link browser display link parents link examples & interpretation hyperlink vs external resource link link syntaxlink href attributelink hreflang attributelink rel attributelink type attributelink itemprop attributelink title attribute