I have a HTML markup for each brand in my page like this
<ul>
<li>
<a title="mallname" href="/brand/mallname">
<div class="image">
<img src="/Images/mallname.png" alt="mallname" />
</div>
<div class="title">
<h2>mallname</h2>
</div>
</a>
</li>
</ul>
is that heading
position ok inside a hyperlink
, or should I change it to
<ul>
<li>
<h2>
<a title="mallname" href="/brand/mallname">
<div class="image">
<img src="/Images/mallname.png" alt="mallname" />
</div>
<div class="title">
mallname
</div>
</a>
</h2>
</li>
</ul>
which one is the more right way to write it, and what is the result that will be read by crawler
for the heading
in both case?
If in the first one, the heading
content is only mallname
, will the second one be read as mallname mallname mallname
as there is a title
attribute in the hyperlink
and alt
attribute in the image
inside the heading
here's one of the result of the list item
In your first example, the h2
doesn’t describe the content of the li
. In scope of this heading is everything following it, until the next heading starts. So in fact, the previous heading would describe the following content, and so on. This problem always arises when using headings without sectioning elements in lists.
In your second example, the h2
probably contains more than it should (two times "mallname"; the one in the title
attribute is not considered to be part of the heading content). But what is the actual content here? There is only a heading, which doesn’t seem to make sense.
Your alt
content is probably not correct/useful. When it is exactly the same as the corresponding heading, the you should probably use an empty alt
value. But it’s likely that the image represents something in addition to the heading: describe this in the alt
content.
Duplicating the heading content in the title
attribute doesn’t seem to make sense, either. Only use it for additional helpful (but not essential) content.
So you should use something else: sectioning elements. Judging from the screenshot, it might be the case that article
is appropriate (if not, use section
).
By using a sectioning element like article
, the heading doesn’t have to be placed on the top.
<ul>
<li>
<article>
<a href="/brand/mallname">
<img src="/Images/mallname.png" alt="Mallname offers … and …. It’s ….">
<h2>mallname</h2>
</a>
</article>
</li>
</ul>
However, use this only when the h2
describes the ìmg
! When the image is only an alternative to the heading (or only decoration, and the actual image content isn’t relevant in this context), why use headings at all? In that case you’d have just a list of links:
<ul>
<li><a href="/brand/mallname"><img src="/Images/mallname.png" alt=""> mallname</a></li>
</ul>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments