a type attribute
The type attribute on the a element:
- allows you to specify the media (MIME) type of the linked resource; information useful for user agents
- type is a specific attribute → can be applied ONLY on the next HTML5 elements: a, area, button, embed, input, link, menu, menuitem, object, ol, script, source, style
MIME types Examples for different resources:
- - image⁄png (for .png image format: image.png)
- image⁄gif (for .gif image format: image.gif)
- image⁄jpeg (for .jpeg image format: image.jpeg)
- image⁄pjpeg (for .jpeg image format in IE: image.jpeg)
- image⁄vnd.microsoft.icon (for .ico image format: favicon.ico)
- text⁄css (for .css file format: style.css)
- text⁄html (for .php file format: index.php)
- text⁄javascript (for .js file format: script.js)
- audio⁄ogg (for .ogg audio file format: sound.ogg)
- audio⁄mp4 (for .mp4 audio file format: sound.mp4)
- video⁄ogg (for .ogg video file format: video.ogg)
- application⁄zip (for .zip file format: file.zip)
Examples
<a | attribute | = | "value(s)" | > | ... | <⁄a> | example |
---|---|---|---|---|---|---|---|
7. | type | = | MIME type | <href="file.php" type="text/html"> ... <⁄ > |
Video demonstration a type attribute
HTML5 a type attribute Tutorial
min | video details |
---|---|
00:08 | video tutorial: a element, type attribute objective: understanding the type attribute |
00:16 | the type attribute: - is optional - can be used only if href attribute is present - allows you to specify the media type of the linked resource |
00:24 | we have 2 a elements, both have the href attribute → we can add the type attribute also |
00:31 | the 2 a elements, link the html file to 2 external different resources: html, css |
00:34 | 1st resource is html type (opens an html page) |
00:46 | 2nd resource is css type (opens a css page) |
00:59 | MIME types |
00:59 | the MIME type of these 2resource is different: - the MIME type of the html file is: text⁄html - the MIME type of the css file is: text⁄css |
01:08 | this information (the MIME type), useful for user agents, can be added through type attribute |