07 XHTML Images & Multimedia - PR - TM
07 XHTML Images & Multimedia - PR - TM
uk
CSC1014
Topics
Basic principles Images in XHTML Image file types
GIF JPEG PNG
JISC Netskills
CSC1014
Basic principles
Any page content that isn't text requires the browser to be capable of handling it Some content will have native support
Built in to browser no extra software needed Core image formats supported by all browsers Increasingly HTML5 will allow native support for video/audio too Heavier duty work and proprietary objects Flash player, Java VM, Media player, QuickTime etc
Others will require plug-in/helper applications A browser may include some plug-ins by default
JISC Netskills
CSC1014
Images in XHTML
Uses the replaced <img> tag
Browser retrieves image from location specified in src attribute Image is displayed in the page i.e. replacing the <img> tag
<img src="logo.gif" alt="My Logo" height="100" width="100" />
alt attribute used to display text/contextual information for screen readers (and if the image fails to load)
The src & alt attributes are required by the XHTML spec The image is not stored in the document
i.e. a web page with 5 images = 6 requests for files
JISC Netskills
CSC1014
CSC1014
Image attributes
Attribute
src
Purpose
Specifies a URL location (relative or absolute) from which an image file can be retrieved A meaningful description of an image to be used by screenreaders (or if image fails to load) Pixel dimensions for the space the browser should allow to display the image Provides a descriptive tag for the image
Notes
Images can be located anywhere the browser can access An alt attribute is required by the specification. It can be empty i.e. alt="" for purely decorative images Changing these does not alter the size and shape of the image. Use an image editor to resize images The text in a title attribute is usually rendered as a tool-tip when the mouse hovers over the image
alt
JISC Netskills
CSC1014
JPEG (.jpg)
16 million colour palette good for photos Lossy compression - take care Careful use = small file size + high quality Open-source format with loss-less comporession Conceived as an improvement on/replacement for GIF Handles higher resolution images, transparency etc.
PNG(.png)
JISC Netskills
CSC1014
JISC Netskills
CSC1014
45K 8K
Over compressed
4K
60K
JISC Netskills
CSC1014
PNG much better for illustrations and complex graphics Photographic images with complex colours usually better (and smaller) with carefully created JPEGs
http://www.turnkeylinux.org/blog/png-vs-jpg
JISC Netskills
CSC1014
Most cannot be played natively in the browser and require O/S support and/or a specific plug-in Common formats
Java, Adobe Flash, Apple QuickTime, Windows Media, MP3 audio etc
JISC Netskills
CSC1014
Originally proprietary tags added by browser manufacturers <applet> (Java applets) became part of HTML spec <embed> (Netscape) widely supported but never adopted in any standard HTML version Current, correct, way is to use <object> and <param>
JISC Netskills
CSC1014
Using <embed>
The most widely used method
Mostly due to support for older browsers (which don't exist now!)
<embed src="http://blip.tv/play/AYGJ7iIA" type="application/x-shockwave-flash" width="525" height="424" allowscriptaccess="always" allowfullscreen="true"> </embed>
Newer browsers still support it YouTube (and others) are starting to phase it out
JISC Netskills
CSC1014
Using <object>
Introduced by the W3C in HTML 4.01 as a generic way to include any external object in a page Supported by all current browsers, with some slight differences
type required by Internet Explorer data required by Firefox
<object width="525" height="424" type="application/x-shockwave-flash" data="http://blip.tv/play/AYGJ7iIA"> <param name="movie" value="http://blip.tv/play/AYGJ7iIA" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /> </object>
JISC Netskills
CSC1014
HTML 5?
The proposed specification for HTML 5 includes improved support for media objects New logical tags e.g. <video> and <audio> Expectations that browsers will support playback of some formats without needing additional plugins Default format choice is unlikely to be resolved soon
Focus has been on widely used (proprietary) h.264 video format for MP4 Google Chrome announced a future removal support for h.264 (to focus on their own format) Mozilla won't include h.264 as it needs to be licensed
http://youtube-global.blogspot.com/2010/01/introducing-youtube-html5-supported.html
JISC Netskills
CSC1014
An HTML 5 example
The open source OGG Theora (currently) works in Firefox, Opera & Chrome h.264 works in Internet Explorer 9+ and Apple Safari & Chrome (still)
http://www.w3schools.com/html5/tag_video.asp <video width="640" height="480" src="microblog.ogg" type="video/ogg" controls="controls"> </video>
JISC Netskills
An HTML 5 capable browser will add controls and play the video.
CSC1014
Reference URLs
W3Schools tutorials
http://www.w3schools.com/media/ http://www.w3.org/TR/html5/ http://en.wikipedia.org/wiki/HTML5 http://en.wikipedia.org/wiki/HTML5_video
JISC Netskills