0

I'm using a tool called whacko to parse and manipulate HTML files.

One of the side effects it has is that it turns

<div flex class="flexible">
  <b>Content</b>
</div>

into

<div flex="" class="flexible">
  <b>Content</b>
</div>

And likewise for other empty attributes.

Does this difference pose any problems? Is the flex="" form invalid, does it need to be handled differently?

asfallows
  • 5,998
  • 6
  • 29
  • 48
  • old-school html didn't care. xhtml requires all attributes have values, so `foo` is invalid, `foo="foo"` is fine. and many cases, merely having `foo=""` would be enough to trigger the attribute's special purpose, since it's its PRESENCE that mattered, not its value. i.e. if you didn't want "foo" to take effect, then you did put foo in at all. – Marc B Jan 08 '15 at 20:00
  • @MarcB: That looks like an answer to me. – Scott Hunter Jan 08 '15 at 20:01
  • 1
    @MarcB, HTML5 doesn't require a value, and XHTML is no longer relevant as so few sites ever managed to actually make valid XML. – zzzzBov Jan 08 '15 at 20:02
  • possible duplicate of [Are empty HTML5 data attributes valid?](http://stackoverflow.com/questions/9729080/are-empty-html5-data-attributes-valid) – isherwood Jan 08 '15 at 20:12
  • In HTML4, a _boolean attribute_ is specified using either `flex=flex` or `flex`. Whacko is introducing a potential incompatibility with HTML4 for no apparent reason. Of course, HTML4 doesn't have a `flex` attribute... – Nisse Engström Jan 16 '15 at 22:37

1 Answers1

2

According to the html5 spec, they're the same:

Empty attribute syntax

Just the attribute name. The value is implicitly the empty string.

For XHTML syntax, the value is required explicitly.

fgb
  • 18,439
  • 2
  • 38
  • 52