Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
This course focuses on two elements of web development: accessibility and search engine optimization (SEO), demonstrating why they are important and how they work. Author Morten Rand-Hendriksen also shows how good coding practices and modern web standards can make a site accessible and more visible to search engines and social networks.
The Internet is a fantastic medium for sharing images, but unfortunately, not everyone can see these images. That includes people with vision problems, search engines, as well as people who use browsers that have images turned off or can't display images for some other reason. For people who can't see the image, the web experience can be a dull and often confusing one if no information about the image is provided. That's what the alt attribute is for. When you add an image to a web page, you are usually doing it as an illustration or to convey some message.
The alt attribute in the image tag provides that message in text format so that people can understand it and search engines can understand it. What is really important here is that the alt attribute is required for web standards compliancy; that means if you add an image and you don't add an alt tag, your code is invalid. It needs to be there. The alt tag needs to be in every single image tag for the code to be valid. The accessibility benefit of adding an alt tag is pretty obvious. When you add an alt tag, you are adding a text description of the image, meaning if you can't see the image you see the text description instead, and if you're accessing the website using a text- to-speak browser, you get that text description read back to you.
The SEO benefit is directly related to the accessibility benefit because the search engine cannot see your image. The search engine relies entirely on your alt description to understand what this image is, so that it can be indexed properly. That means if you provide a good description of your image, the search engine will understand what it is. Unfortunately, some people use this to try to up their search engine ranking. They put in images in their pages and stack them with alternate descriptions that often have little to do with the article and have nothing to do with the image itself.
This might seem like a good idea, but the search engines are on to them, and this will actually hurt your search engine ranking quite dramatically. So when you add an alt description to your images, make sure that you do it properly and that you actually describe the image. The image markup looks a lot like the anchor markup, with a couple of small modifications. You start with the image tag. You then add the source attribute which points directly to the image. This is because the image itself doesn't live on your page; the image lives somewhere else and it's called in through a hyperlink.
So in this case, I'm using a root relative link to point to an image called morten.jpg in the Images folder. Then you add the alt tag. The alt tag is simply alt= and then inside quotations marks you type out the description of the page. And then inside the quotation marks, you type out the descriptions of the image. When you have done all this, you close the tag, because the image tag doesn't wrap around anything, since it's only bringing an image in. Depending on the function of the image on the page, what you put in the alt variable will vary.
If the image contains information that is pertinent to your article or the image itself is descriptive, we use the alt tag to describe the image or describe how it relates to the article. If the image is inside a link element, so when you click on the image, you follow a link, the alt variable describes the link target. In other words, the alt variable and the title variable from the link should be the same. Finally, if the image is added as decoration only and has no relation to the topic and no relation to anything else in the page, you should still add the alternate description variable, but you leave it empty.
So you type out alt= and then just two quotation marks. That way the browser will know, here is an image, it has no value to the story, so I will simply ignore it. In our example project we have four images: one big image at the top of the story that relates to the story and three images that link out to other places. Now we can go and change the markup so that all these images validate and have the correct markup. So I'll go in and open index in my Notepad, and then I will find my images.
The first one is in the first part of my paragraph. You find it here, inside the figure tag. It says image class="center" and then we have the source link to the image itself, but we don't have a title. So here I will add a title describing the image. In this case the image is "Yellow Pansies in a pot outside a house." I will end the image tag and now when I save it, I can go and open the page in my browser and when I hover my mouse over the image, you will see we get that message, "Yellow Pansies in a pot outside a house." That also means that the search engine will now index that image as Yellow Pansies in a pot outside a house, instead of just an image.
Looking at the images below, you will see that these images point to another source, and based on the rules about how to use the alternate tag, we now have to match the alternate description of each of the images to the title tag of the links that are pointing elsewhere. So I will go back to my markup and find these images and then I will copy out the title variables and add them to the alt variable in the images. So I will copy this one, and then say alt equals, and I will paste it in.
And then I will do it for this one and for the last one. Now this might seem like doing twice the work for the same results, because as you saw, before I added the alt variables, when I hover over the image, I can see where it's pointing.
Now the reason why you need to do this has nothing to do with the link; it's because you need to provide information about the image itself and its relation to the rest of the content on the page, regardless of whether or not it's wrapped in a link. So the fact that it's wrapped in a link and that the link has a title tag has no impact on the image itself. The image still needs an alternate description. When I reload the page, it doesn't seem like there's any difference, because we still get the same message. The difference only kicks in if something goes wrong with this page.
For example, if I go in and I right- click on the image and go to Inspect Element, and I break the link to the image-- let's say, for instance, it wouldn't load from the server or something like that-- if I go in and take this link out, you will see that in its place, we get the description of the image itself. And because this image was a link, the link now wraps around this text description. Without the text description we wouldn't see this link, so we would have an empty spot without a link and no way of following that link anywhere.
Though the alt attribute is required when posting an image on a web page, it's often overlooked because images work even without the attribute. Adding the alt attribute to your images ensures that they get indexed properly by search engines and that non-visual users can still glean the information they contain.
There are currently no FAQs about Improving SEO Using Accessibility Techniques.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.