/    Sign up×
Community /Pin to ProfileBookmark

structured data in a link

Hi all,
I do not know well the javascript language and I need help on how to add the term “itemprop” to a link to a menu item like this:
<a href=”…” itemprop=”url”> … </a>
I tried to add it as an attribute but it gives me an error saying that “itemprop” is NOT an attribute
Can anyone help me?
Many thanks

Giovanni

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rootFeb 07.2017 — Firstly, this is a javascript forum not HTML... but ...

You have to watch your strings

[code=html]<a href="index.php?itemprop=myProperty">MyLink</a>[/code] this creates an anchor link which will have the link pass itemprop with the value myPorperty to index.php script, you can use this method to pass information between pages in html.

In future, please be aware of two things, firstly getting the right forum, secondly use forum BBCode tags when posting code, html or php code, it makes it easier to read and keeps the formatting of any indentation.
Copy linkTweet thisAlerts:
@Kevin2Feb 07.2017 — This validates:
[code=html]<!doctype html>
<title>itemprop demo</title>
<ul itemscope>
<li><a href="page1.htm" itemprop="url">page 1</a></li>
<li><a href="page2.htm" itemprop="url">page 2</a></li>
<li><a href="page3.htm" itemprop="url">page 3</a></li>
<li><a href="page4.htm" itemprop="url">page 4</a></li>
</ul>[/code]

A couple of links which may help:

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop

https://www.w3.org/TR/microdata/#names:-the-itemprop-attribute

Additionally, [i]itemprop[/i] is an HTML5-only attribute. If you are using an XHTML or HTML4 DOCTYPE (or none at all) you'll get the validation errors you describe.
×

Success!

Help @giozua spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...