Bootcamp Notes – Day 3 (Wed) – Anchors and Multimedia
Anchors and Multimedia
The absolute path will stay the same no matter where the link is coming from. For web browsers, the absolute path is the full URL of the resource, such as https://www.google.com
Link to email: <a href=”mailto:info@somewhere.com”>Email</a>
Anchors and Multimedia
- The <img> element
- <img> attributes
- The <video> element
- <video> attributes
- For visually impaired users using screenreaders.
- If the image cannot be loaded for some reason, the text will show instead.
- It will also help search engines get more information about your webpage.
You can also optionally use width and height to control image size: otherwise, defaults to actual image size. You can specify number in pixels, without unit size – “100” not “100px”.
If you specify only one size or the other, then the browser will autosize the image with original ratio.
Now we talk about the <video> element. It is new in HTML5 and it replaces FLASH and silverlight which were used before to play video. It requires src attribute: path to video file. It also supports these three major video format: MP$, OGG, WEBM
Look at this example below:
<video src=”someVideo.mp4″ controls>Your browser does not support HTML5 video. Here is <a href=”someVideo.mp4″>a link to the video</a> instead. </video>
From the example above, text between start and end tag is called the fallback content. The fallback content shows in browsers that don’t support HTML5 embedded video. It is a good idea to link the video using <a> element so it can still be accessed. The controls is a Boolean attribute which embeds a video player.
Now we can add width and loop to our example:
<video src=”someVideo.mp4″ controls width=”200″ loop>Your browser does not support HTML5 video. Here is <a href=”someVideo.mp4″>a link to the video</a> instead. </video>
Width & height can be specified just the same as with <img>
The loop cause the video to replay when video is finished. If you don’t want the video to loop then just leave the loop out!
Words of advice for autoplaying a video. The autoplay attribute exists but don’t use it!
Additional Resources