2

I am marking up my content with schema.org microformats and am wondering about the itemscope attribute. The example given on http://schema.org/docs/gs.html is

<div itemscope itemtype="http://schema.org/Movie">

Is this valid HTML5? I thought attributes needed values, something like

<div itemscope="itemscope" itemtype="http://schema.org/Movie">
Tom Kincaid
  • 4,887
  • 6
  • 47
  • 72
  • 1
    It may be valid now however some older parsers may not treat it as such. For example com.sun.org.apache.xerces.internal.parsers.DOMParser.parse will throw a SAXParseException "Attribute name "itemscope" associated with an element type "div" must be followed by the ' = ' character." – Brett Y Nov 26 '19 at 09:31

4 Answers4

10

It's a boolean attribute, which is valid HTML5.

If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.

Tomas M.
  • 13
  • 5
zzzzBov
  • 174,988
  • 54
  • 320
  • 367
2

If you want to produce valid XHTML5 (as opposed to HTML5 per se, which does not need to be well-formed XML), then @itemscope will need a value. Per the specs for boolean attributes linked by zzzzBov, to be valid XHTML 5 it will need to be one or the other of empty string or the attribute name, i.e. either <div itemscope=""> or <div itemscope="itemscope">

DavidSewell
  • 71
  • 1
  • 3
1

As zzzBov said, it is valid HTML5.

Same thing with input fields and other types of content:

<input type="text" value="Text goes here" disabled>

Instead of disabled="disabled", HTML5 reads this as true because disabled is present.

Steph Rose
  • 2,126
  • 3
  • 23
  • 35
0

Simple answer - <div itemscope itemtype="http://schema.org/Movie"> is correct.

Example usage

Spec on itemscope

myconode
  • 2,518
  • 1
  • 26
  • 28