let’s say I have some html document with a lot of text. Is it “good” (~not bad :)) to have elements that contain microdata and hide those elements so that user won’t actually see them?
Let’s say I have this:
<div style="display:none" itemscope...>some microdata describing div below</div>
<div> There is actual text that is described by microdata</div>
The point is that this way it may be easier to describe the 2nd div. You don’t have to make changes in whole text, just add some elements and hide them. I want to create simple HTML editor that would support creating microdata and this way seems to be easier to implement and personally easier to use (first create actual content, then annotate it).
Hiding content marked up with Microdata sort of defeats the point of it, it is intended to add additional information about stuff that’s already visible on the page. The main argument for this is that people always remember to update visible content, but frequently forget to update content they can’t see, so hidden ‘meta’ content is frequently out of date and inaccurate. Microdata instead takes the approach of describing what the visible content is, so if the content changes the data it produces changes. Take this example from the spec:
If you change the visible content none of the Microdata markup actually changes:
So Microdata is almost certainly not what you want to use in your situation. What you really ought to use instead depends on exactly what you want this information for. If you want to add hidden data for processing with scripts on your site then instead use
data-*attributes. If you want to add additional descriptive information that not all users need to see, consider using ARIA. Particularly, in your case,aria-describedby.