Wordpress - How Can I Add Alt Tags To Menu Links?

I need to include an 'alt' tag in my wordpress menu links.

Right now, the menu links include the title tag, but not the alt tag.

I'd like the alt tag to include the same thing as the title tag.

I have this in my menu links:

<a title="Home" href="http://www.mysite.com/">Home</a>

but need this:

<a title="Home" alt="Home" href="http://www.mysite.com/">Home</a>

Suggestions? Seems like there should be something I could add to my functions.php to do this, but I have no idea what.

Thanks for any help!

Chris
St_Aug_Beach_BumAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason C. LevineNo oneCommented:
Why do you want alt in the <a> tag?  It's not valid there, which is why title is used.  If you add it, you will break HTML validation...

ref: http://www.w3.org/TR/html5/text-level-semantics.html#the-a-element
0
St_Aug_Beach_BumAuthor Commented:
Ha, that's funny - I had a feeling someone would ask 'why do you want to do that!'.

I considered including the answer in the question, but figured I didn't really need to get into the 'why', just the 'what'.

But since you asked....

Google lists my site with sitelinks below the main page.

However, the sitelinks are not the main links it should be using. It's using some that are actually second and third level category links.

On Google's sitelinks page:

https://support.google.com/webmasters/answer/47334?hl=en 

they say that to help their algo pick out the right links -  "make sure you use anchor text and alt text that's informative,..."

Interesting, eh? But that's what it says.... so I'd like to try it and see if it makes a difference,

Chris
0
Tom BeckCommented:
What Google means...

Anchor text:

<a href="http://somedomain.com">Anchor Text</a>

Alt text:

<a href="http://somedomain.com"><img src="http://somedomain.com/img.jpg" alt="This link text is informative" /></a>
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

St_Aug_Beach_BumAuthor Commented:
So you're saying they mean "or", not what they have, which is "and"...
0
Tom BeckCommented:
"And" is semantically correct if you have multiple links on the page where some are text links and some are image links. I don't think Google would knowingly suggest that you put alt attributes in anchors.
0
Jason C. LevineNo oneCommented:
Correct.  Google is telling you to use good anchor text between your <a> and </a> Text links or if you are using linked images, to use alt text.  They wouldn't tell you to write invalid HTML.  

That being said, you might have to hack the core (bad) or disable the internal menu system and add your own to header.php to do what you propose to do.  I don't see a way to do it via a filter.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
St_Aug_Beach_BumAuthor Commented:
Thank you both.

Well, I've added a title text to the anchors, which I didn't have before. I don't know if that will affect anything, but I'll watch and wait (without adding alt) and see if that helps at all. If not, I'll go back to the drawing board.

Thanks goes to both of you,

Chris
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.