So do I need to follow some guidelines regarding the length of an alt
property?
There is no set maximum length for the value of alt
tags, however, most advise for the benefit of sight impaired users to keep it under 125 characters - see this and this.
I have the same question regarding the title property.
In regards to title attributes, like with the alt
text, there is no set maximum length. However, since this is used for tooltip text for an element, usability for the visually impaired should also be considered as the W3 covers here, suggesting that the 125 character size would similar apply. You may also find through browser compatibility testing, that the tooltip will get cutoff after a certain length, varying by browser.
Since title property might also refer to title element, search engines like Google will truncate your title element, or even compose their own based on your content, if it's too long. As suggested here by MOZ, the goal should be to keep it to under 70 characters or less:
Title Tag: Best Practices for Length
Aim for title tags containing fewer than 70 characters. This is the
limit Google displays in search results. Title tags longer than 70
characters may be truncated in the results, or search engines may
choose to display different text from the document in place of the
title tag. Recent experiments have shown that the number of characters
displayed in the search results may also vary based on—among other
things—the width in pixels of each letter. 70 characters is still a
good general guideline for length, though.
title
'property' (i.e.<img href="image.jpg" title="image title goes here">
). But @dan twice edited 'property' to 'attribute and then to 'element'. And now I'm not sure which term is correct in this way.title
attribute is what can appear inside theimg
element (or tag). Thetitle
element, on the other hand, is the main title of your page that goes in thehead
section. (You seem to have answered this in comments below.)src
,href
, etc. (data within a tag) are HTML attributes.