The img tag and how it can super power your food blog

The img tag and how it can super power your food blog | foodbloggerpro.com

Do you have a favorite super hero? I have always been fascinated with Mighty Mouse. I love the idea of a tiny little mouse that has a really big impact.

There are a lot of different “Mighty Mouse” elements that exist when you’re growing a blog. These are seemingly small or unknown things that in actuality have a big impact on the success of your blog. One of these “Mighty Mouse” elements is the img tag. In today’s post we’re going to dissect the img tag and explain how it can super power your food blog.

Want to practice doing some of this on your own? You can click on the button below to download the images and text that I’ll use in the examples.

Download Lesson Files

What is the img tag?

The img tag is the HTML code used to communicate information about an image to a user’s web browser. When looking at a website, we humans see images, but your computer sees HTML code.

I think the best way to understand is by doing, so let’s jump in and explore this together.

  1. Login to your blog (we’ll be using a WordPress blog in this example).
  2. Hover over Pages and select Add New (don’t worry, we won’t be publishing this page).
    Adding a new page in WordPress
  3. Add a title of Chocolate Chip Muffins and then click Add Media.
    Adding media to a WordPress post
  4. Drag the chocolate-chip-muffin.jpg image from the lesson material folder into the Insert Media window.
    Drag file to import media window
  5. Fill in the Attachment Details and Attachment Display Settings like the screenshot below. Click Insert into page.
    Attachment Details and Attachment Display Settings
  6. After clicking Insert into page, WordPress will drop the image into the page. Now let’s take a look at the HTML code that WordPress is using behind the scenes. We can see the HTML code by clicking on the Text tab in the top right corner.
    Switching to the text tab in wordpress
  7. Cool! We’re now looking at the img tag exactly as a web browser would see it when it comes to our blog.
    The img tag in WordPress

The begin and end of the img tag

The first part we need to look at is the img tag itself. I put a red box around the beginning and the end of the image tag. The first red box shows where the tag starts, and the second red box shows where the tag stops.

img tag opening and closing

It’s important to know where the beginning and end of the tag is so we can examine everything that’s inside of it. The parts that are inside of the tag are called attributes. Let’s take a look at the four attributes that are inside of the img tag and talk about how they can super power your food blog.

1. The class attribute

The class attribute

We’re not going to spend much time with the class attribute, as you’ll only use it if you’re familiar with CSS (CSS is a type of code that helps you add style to websites). One thing that is important to point out in the class attribute area is the “align” class. In our example above, the align class is set to alignnone.

As the name implies, this is the way that your image is aligned in the post. There are four choices for alignment that you can pick from when putting an image into a post: Left, Center, Right and None.

Alignment options in WordPress

Here’s how those alignments look:

alignleft

WordPress alignleft class

aligncenter

WordPress aligncenter class

alignright

WordPress alignright class

alignnone

WordPress alignnone class

Nerd note: If you want to switch your image’s alignment you can just change the text in the class attribute. For instance, we can change our example image to have a left alignment by changing alignnone to alignleft.

There are two other classes we see, size-full and wp-image-16139. These are not classes that we’ll need to change or adjust manually.

That’s all that we need to know with the class attribute for now. Let’s move on to the alt attribute.

2. The alt attribute

The alt attribute

It’s easiest to remember the alt attribute as the alternative attribute, as in what text should be displayed as an alternative if, for whatever reason, the image can’t be displayed.

There are three reasons why the alt attribute is really important:

  1. Usability: It communicates information about your image to visitors that are visually impaired.
  2. SEO: It communicates to search engines what your image is about.
  3. Pinterest: It’s the information that is auto populated into the description area when an image is pinned from your site.

1. Usability

Visitors that are visually impaired will use a screen reader to process the information on websites. A screen reader will go through the different parts of a website and attempt to read back information to the user. This works really well for text, but it doesn’t work as well for images. Providing descriptive text in your alt attribute supplies the screen reader with content that can be read back to the visitor, enabling them to better understand what the image is about. Imagine how you would describe your image to someone that is visually impaired. That’s a good starting point for what you should put in as your image’s alt attribute.

2. SEO

When a search engine like Google comes to your site it will crawl through your page and attempt to understand the information on your blog post. Search engines are really good at understanding text, but not so great at understanding images. That’s why the alt attribute and the image’s file name (more on that later) are so important for your food blog’s SEO. If your file name is IMG_9205.jpg and the alt attribute area is empty, then you’re not giving Google any clues to help it figure out what your image is about. Providing an accurate and informational alt text helps Google understand your image.

Nerd Note: Never try and trick Google by “stuffing” a bunch of words into your alt attribute in an attempt to help your post show up higher in Google. This would be an example of “black hat” SEO and could actually end up hurting your blog’s rank in Google. Just do your best to provide an accurate description of the image.

3. Pinterest

Understatement: Pinterest has the potential to drive traffic to your food blog.

If you have a post that becomes popular on Pinterest it has the potential to send HUGE amounts of traffic to your blog. The most important part of a viral Pinterest post is how an image looks, but the alt attribute also plays a really important role when an image is pinned. This is because the default description for a Pinterest pin is the text in the image’s alt attribute.

That’s a really important point, so I’m going to repeat it: The default description for a Pinterest pin is the text in the image’s alt attribute.

Here’s an example:

The impact the alt tag has when using pinterest

A creative, eye-catching description can go a long way with Pinterest.

Want to take it a step further?

Here’s a Food Blogger Pro certified “super tip”: Include your blog’s URL at the end of the alt attribute. The URL will be clickable once the image gets pinned to Pinterest and will act as a direct link back to your site.

Here’s an example:

Include your blog's URL in the alt attribute so it shows up in Pinterest

Here’s an example of some Pinch of Yum pins that include the URL in the description so you can see how this really looks on Pinterest: https://www.pinterest.com/search/pins/?q=pinchofyum

Can you see how it’s a major benefit to have your blog’s URL in the description of a Pinterest pin? Pretty darn cool.

3. The src attribute.

The src attribute

The src attribute is telling the browser where the image is located on your server. It’s easiest to remember the src attribute as the source attribute, as in this URL is the source of the image.

This isn’t critical to know, but I think it’s interesting: Your blog’s images are organized the same way that they would be on a computer — where every image is stored in a folder. So, if you’re using WordPress, the URL for your src attribute will usually look like this:

http://yourblogname.com/wp-content/uploads/2014/01/your-image-name.jpg

In our example, the URL is:

http://pinchofyum.com/wp-content/uploads/2014/01/chocolate-chip-muffin.jpg

  1. That means that there is a folder on our server called wp-content:
    pinchofyum.com/wp-content/uploads/2014/01/chocolate-chip-muffin.jpg
    WordPress folder structure for media
  2. …and in that folder there is another folder called uploads:
    pinchofyum.com/wp-content/uploads/2014/01/chocolate-chip-muffin.jpg
    WordPress folder structure for media
  3. …and in that folder there is another folder called 2014:
    pinchofyum.com/wp-content/uploads/2014/01/chocolate-chip-muffin.jpg
    WordPress folder structure for media
  4. …and in that folder there is another folder called 01:
    pinchofyum.com/wp-content/uploads/2014/01/chocolate-chip-muffin.jpg
    WordPress folder structure for media
  5. …and in that folder we can find our image:
    pinchofyum.com/wp-content/uploads/2014/01/chocolate-chip-muffin.jpg
    WordPress folder structure for media

FBP Members: If you want to see how to access these files and folders on your blog you can watch the FTP course in the Essential Tools topic area.

Nerd Note: You can actually copy the URL in the src attribute and paste it into your web browser like it is a website. When you do that it’ll bring you to a web page, but the only thing on the page will be the image.

The most important thing to consider with the src attribute is the file name that you give to the image before uploading it. The file name is important because search engines use it to try and figure out what your image is about. If your image is of a chocolate chip muffin, make sure that you don’t have a file name of IMG_9205.jpg, because that’s communicating to the search engine that your image is about “IMG_9205.jpg,” which doesn’t really make sense.

It would make much more sense if you call your image chocolate-chip-muffin.jpg, because that’s the actual content that is in image. This is an important concept, so I’ll bring in some emojis to help make my point.

SEO Tip - Ideal Image File Name

There are lots of different ways you can change the file name of an image. Here’s how I usually do it:

  1. Click on the file
  2. Press return (enter) on your keyboard.
  3. Type in the new file name.
  4. Press return (enter) to finish editing.

Renaming an image's file name

You want to do this before you upload the image to your blog, as it’s really hard to change the file name after you uploaded the image.

4. The height and width attributes

The height and width attribute

WordPress should automatically add these attributes to your img tag, but if they’re not included you need to add them. The height and width attributes are important because they save the web browser from having to measure the image’s file size on it’s own.

It’s kind of like handing someone a picture and asking them to go buy a frame for it. If you start by first telling them the exact dimensions of the picture then they’ll be able to quickly find the correct frame size. If you don’t tell them the dimensions then they’ll have to measure the picture before buying the frame, which takes a lot longer.

The same is true for images online. If you tell the web browser the size of the image then it doesn’t have to measure the image on it’s own, which means your page will load faster.

Linking an image to an image 🙁

Occasionally I’ll notice a blog that is linking all of it’s images to a page that is just another picture of that image. I’ll provide an example below. If you hover over that image you’ll see that you can click on it. When you do click on it you’ll notice that it opens a new window that contains the same image.

Blueberry Muffin

This doesn’t hurt anything, but it’s considered poor form (unless you’re linking to a larger version of the same image to allow the visitor to see it better).

The issue comes from having “Media File” selected under “Link To” when you first add the image to your post.

Link to Media File

You’ll usually want “Link To” set to “None.”

If you notice this issue on old posts and you’d like to fix it you can remove the anchor element (highlighted in red below) that is wrapped around the img tag.

Anchor Element around IMG tag

Editing and updating your img tag

We’ve dissected the img tag and understand the attributes that are located inside, but how the heck do you put them in correctly in the first place (or edit them if you know you’ve done it wrong in the past)?

Attachment Details and Attachment Display Settings

The easiest way is fill out the information in the Attachment Details and Attachment Display Settings when you’re first adding the image. It’s insanely simple, but many people rush through this part. The screenshot below shows a basic example of an image with properly formatted Attachment Details and Attachment Display Settings.

Attachment Details and Attachment Display Settings

Nerd Note: Here’s a quick explanation on the other fields in this screen: (1) The title attribute is no longer used in WordPress, so it’s not a critical area to fill out. (2) It’s rare to see a caption used on a food blog (as the pictures are pretty self explanatory. (3) The description is for your own internal use and won’t show up when you insert the image.

Editing the HTML in the text tab

At the begin of this post we switched our editing screen from the Visual tab to the Text tab. Once you’re in the Text tab you can easily update the different attributes of the img tag. Although you can technically change all of them, the only one you’ll really want to change is the alt attribute (and possibly the alignment class).

Editing the alt attribute in WordPress

Conclusion

Did you make it all the way through this post? If you did then you’re the kind of person that’s serious about growing your food blog. 🙂

I just threw you a virtual high five for going above and beyond and taking the time to understand the img tag. Remember: it’s all about small changes that can have a big effect on your blog. I’m off to watch some Mighty Mouse on YouTube!

Leave a Comment

Your email address will not be published.

39 Comments

  1. I just read this for the third time and realized that I have not mighty moused my img tags 100%. (Hangs head in shame)

    Off to remedy this!

  2. Thank you so much for this. So helpful! We are not a food blog. We use images in our posts to brighten up the page. The image doesn’t always specifically reflect the words in the post (at least not the way a chocolate chip muffin image goes with a chocolate chip muffin recipe). If I name my images with names that go with our posts (e.g. “unconditional love”), will that bring people to our page because of how I named the image? I am also doing some other things in the title, text and permalink to help with SEO. But do you think I should also name my images with the title of the blog post? Thanks!

    1. Great question Gem. I’d create file names that match what the image is about, not necessarily the post. If it’s an image of a father hugging a son you could name it father-son-unconditional-love.jpg. That might be a little long, but you get the idea. 🙂

  3. Hi Bjork, thanks very much for this post. I’m having trouble with my alt attribute and was wondering if you have any insight! It seems like Pinterest is pulling the description of my photos from my post title, not the alt attribute. I’ve added my website domain to some of my alt tags to test this. When I pin the photo, the title of my post comes up in the description and no website domain.

    It’s even worse on a mobile device. A quick example – I wrote a post called “Baking Tip – Homemade Baking Powder.” The alt description is simply “Homemade Baking Powder.” However, when I click the pin it button on my website, this is what comes up in the description on pinterest – “Baking+Tip+-+Homemade+Baking+Powder.” Does the plugin have anything to do with this? Thanks!

  4. Hi Bjork, I made it to the end of the post 🙂 Question for you though – I went back into my last recipe post (http://www.jamjnr.com/2014/… and changed the alt description to include my blog name and I have checked the text format to make sure the new alt name is in the tag – get me being all technical! But – when I try to pin the photo the new alt description doesn’t show up in the pin description.

    Is this because of the pinterest plugin I’m using? I’m using Pinterest Pin It Button – or is there no point going back and changing the alt description on old posts?

  5. Bjork, this was really helpful! I do have one question…I usually change all of the image names before uploading them. Is there a way to change the ALT tags without doing each photo individually?

    1. I don’t know of a way to do a mass update for the ALT tag. However, if you name your images without dashes before uploading it then WordPress will use that text and automatically put it into the Title field. From there you can just copy and paste the Title field into the Alt field.

      Does that make sense? Did it answer your question?

  6. I have not been doing this (for shame!) and am wondering how time consuming/hard it is to go back to old posts and re-name images? Would you recommend re-doing them or just implement it moving forward? Thank you for EVERYTHING!

  7. I subscribed to your blog ~ 4hours ago and it is 4 am in the morning and I am still reading your blogpost (along with some others) :O You gave some really good information/tips here. I had no clue about it at all. Thankfully (not really! but jut for this reason) I have just four posts up on my one month old food blog. I have been struggling with images since I started. Can I ask you what should be the best image file size for a blog post? Also, can you suggest a good way or plugin to reduce the size yet keep the visual quality intact? Thanks. PS: I love both your blogs and you two are amazing 🙂 !

  8. Today we are introducing Google Tag Manager API, a new simplified interface and additional support for 3rd party tag templates.

    If you are already using Google Tag Manager you can try the new features by upgrading your account.

    Test and Tag

  9. And if the post has 3 images of the “Chocolate chip muffin” for example, then title and the alt text could be: Chocolate chip muffin 1, Chocolate chip muffin 2… or how should it be? thanks!!!

      1. Thanks! But then if in a post we have 3-4 photos of the same and we have to avoid numbers, the title and the alt text shoud be the same in the 3-4 photos? Or we put similar title and alt text? thanks!!!

        1. I’d try and make them a bit different. So, for example, chocolate-chip-muffin.jpg and chocolate-chip-muffing-bite.jpb and chocolate-muffing.jpg, as opposed to chocolate-chip-muffin.jpg, chocolate-chip-muffin-2.jpg, and chocolate-chip-muffin-3.jpg

          Does that help? Or am I still misunderstanding? 🙂

  10. Thanks Bjork! That was an awesome tutorial! One little question: Is is beneficial to add the name of your blog to any images or just images that are pinned on Pinterest (alt text)? My blog crazydealicious.com is a combination of recipes and deals. I pin only recipes, so I am curious, if adding the blog name would be beneficial with deal images as well…

  11. Thanks so much for the great tips! I had no idea what the alt text was for. Now I’ve got a whole lot of photos with weird names I need to fix. 🙂

  12. Bjork and Lindsay-you’re the bombs! I didn’t know about the “Link to” setting. Plus I love your super tips to add the url to the alt tag. I know this, but tend to forget! Thanks for the reminder. It was great to connect this past weekend at #ssbc15 in NOLA. I’m buried with work (in a good way) creating my free ebook and autoresponders list. Thank you both SO much.

  13. Hi Bjork, I recently signed up and I can’t see the images in this post. Am I missing something? I also downloaded the lesson files. Thanks in advance!

    1. Hey Cindy. We made some updates to the site so I just had to clean out a little bit on the blog post. You should be good to go now.

  14. Hi Bjork! Thank you very much for the tips – it’s incredibly helpful. I am going to change file names before uploading the pictures from now on. But in the posts that are already in my website can I just change the alt text by editing the post or do I need to rename all the pictures and upload them again? My blog is new there are just about 4 posts to correct. Thank you!

  15. This was an amazing post! Thank you so much for sharing this information. I feel as though this can be applied to all types of blogs! All around good information. I basically went through and made all changes as I read this post!

    Tiffany @ arrowsandawe.com

  16. This was awesome. Thank you so much. I have one question: At the end of the article, when mentioning the chocolate chip muffin and the visual where you filled out ‘Chocolate Chip Muffin’, I noticed you did not enter in your website URL there. So, should I change the alts to match the images, as well as input my website URL after each one? Wasn’t sure if the URL thing was just for one picture that will be the pinterest image, or do that will all of the images when it comes to alt text? Sorry! I ask so many questions all the time 🙂 Thanks again and really excited for Food Blogger Pro! Cheers, Jennifer @ fromentfree.com

  17. I’ve always (don’t ask me why) copied and pasted my meta description into the alt text box and the description box. I’m taking away that this is not necessary. I thought PInterest liked the entire meta description and picked it up from the alt text box.