KaanA
KaanA

Reputation: 31

svg inline in HTML5 and svg custom attribute

<!DOCTYPE html>
<html>
...
<body>
<svg version="1.1" id="svg1" data-kind="myvalue"></svg>
</body>
</html>

When I tried to validate the code above on w3 site, I recieved the error below.

Error: Attribute data-kind not allowed on element svg at this point. ...svg version="1.1" id="svg1" data-kind="button">

How can I write a custom attribute in html5 for inline SVG and how can I create a custom namespace or dtd. I will be approciated if you can show and example or tutorial. I will be waiting for your help about how to solve this problem.

Upvotes: 3

Views: 976

Answers (1)

unor
unor

Reputation: 96737

In HTML5, svg is an element from the SVG namespace.

So it is not an HTML element.

Thus you can’t use attributes that are defined for HTML elements only, among them the custom data-* attributes or Microdata attributes etc.

It’s also not possible to use data-* attributes inside of SVG documents.

Upvotes: 4

Related Questions