Rectangle 27 0

jquery Microdata vs. the data attribute in modular HTML5?


<div class="wrapper" id="module1">
  <script type="text/plain" data-userDoesSomething="alert('Data attributes are better!');">
  </script>
  Module-specific content
</div>

<div class="wrapper" id="module1">
  <script type="text/plain" data-userDoesSomething>
    alert('Data attributes are better!');
  </script>
  Module-specific content
</div>

<!-- etc. -->

@AliGajani: Anyone can create Microdata vocabularies (not standards), just like someone created the schema.org vocabulary. And Microdata also allows for "local" vocabularies which dont need to be published in the first place. A local Microdata vocabulary and the use of data-* attributes are similar, as both are not indended to be (re)used by others. However, the use of a "real" (published) vocabulary is typically intended to be used by others, too.

@AliGajani: You (= the webpage author) can do whatever you want with data-*. The point is: the content is "private" to the page. No-one else is intended to make use of it.

How are data-* attributes different from microdata? And are you saying that you can create your own Microdata standard? I don't get it. Explain

However, if you want to use some other Microdata vocabulary (e.g. schema.org) on your pages in the future, you might get some conflicts with your "local" Microdata. So Id not use Microdata if it doesnt offer you benefits over data-* attributes.

I thought the data-* attribute was used to store whereas Micro-data was used to define, am I missing the point here. I haven't seen people use data-* for semantic purposes, its usually like data-dismiss="modal".

Instead of text/plain, you could use whatever suits your needs (JSON, HTML, ).

Microdata is not only for "typed data". You could define your own Microdata vocabulary, if you like. But you could also use a "local" one (emphasis mine):

Regarding the meta element: You can get something similar with data-* attributes, too. In HTML5, the script element can be used for "data blocks". So you could use something like:

That's why search engines use Micro-data and not data-*. Right, thanks unor.

The examples in the previous section show how information could be marked up on a page that doesn't expect its microdata to be re-used. Microdata is most useful, though, when it is used in contexts where other authors and readers are able to cooperate to make new uses of the markup.

Note
Rectangle 27 0

jquery Microdata vs. the data attribute in modular HTML5?


<div class="wrapper" id="module1">
  <script type="text/plain" data-userDoesSomething="alert('Data attributes are better!');">
  </script>
  Module-specific content
</div>

<div class="wrapper" id="module1">
  <script type="text/plain" data-userDoesSomething>
    alert('Data attributes are better!');
  </script>
  Module-specific content
</div>

<!-- etc. -->

@AliGajani: Anyone can create Microdata vocabularies (not standards), just like someone created the schema.org vocabulary. And Microdata also allows for "local" vocabularies which dont need to be published in the first place. A local Microdata vocabulary and the use of data-* attributes are similar, as both are not indended to be (re)used by others. However, the use of a "real" (published) vocabulary is typically intended to be used by others, too.

@AliGajani: You (= the webpage author) can do whatever you want with data-*. The point is: the content is "private" to the page. No-one else is intended to make use of it.

How are data-* attributes different from microdata? And are you saying that you can create your own Microdata standard? I don't get it. Explain

However, if you want to use some other Microdata vocabulary (e.g. schema.org) on your pages in the future, you might get some conflicts with your "local" Microdata. So Id not use Microdata if it doesnt offer you benefits over data-* attributes.

I thought the data-* attribute was used to store whereas Micro-data was used to define, am I missing the point here. I haven't seen people use data-* for semantic purposes, its usually like data-dismiss="modal".

Instead of text/plain, you could use whatever suits your needs (JSON, HTML, ).

Microdata is not only for "typed data". You could define your own Microdata vocabulary, if you like. But you could also use a "local" one (emphasis mine):

Regarding the meta element: You can get something similar with data-* attributes, too. In HTML5, the script element can be used for "data blocks". So you could use something like:

That's why search engines use Micro-data and not data-*. Right, thanks unor.

The examples in the previous section show how information could be marked up on a page that doesn't expect its microdata to be re-used. Microdata is most useful, though, when it is used in contexts where other authors and readers are able to cooperate to make new uses of the markup.

Note