I'd like to add custom attributes to the <div>
tags in my HTML. Is there a way to append those variables to the Doctype description, or should I not even worry about it. I found a similar question on StackOverflow, but it addressed XHTML.
Asked
Active
Viewed 1,052 times
0

Community
- 1
- 1

Brandon Lebedev
- 2,717
- 6
- 24
- 35
-
2what are you trying to do exactly? why does it need custom attributes? – Joseph Dec 16 '11 at 17:14
-
1No need to do so as far as I am aware. After all it is not standard. – Fabián Heredia Montiel Dec 16 '11 at 17:14
1 Answers
2
You can create your own DTD, but not sure how some browsers might react to it, so you will have to test.
http://www.cs.tut.fi/~jkorpela/html/own-dtd.html
edit: overall it depends on what you are doing. It's best if you can avoid a modified dtd.
.. I had to find it, but once I did something like this to get past validation (using propietary code, and couldn't change much at the time, but wanted to get it as close to valid as possible)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" [
<!ATTLIST DIV
something CDATA #IMPLIED
>
]>
if there was something in the code like:
<div something="nothing"></div>
And I wasn't allowed to change it.
The problem is that you can't leave it in the page, because it will probably print out the "]>", but it works for defining an extra attribute for a validator.

craniumonempty
- 3,525
- 2
- 20
- 18
-
1Browsers do not care about DTDs. They only care about doctype declarations as strings, for the purposes of selecting Quirks vs. “standards” mode, and any customized doctype triggers “standards” mode. – Jukka K. Korpela Dec 16 '11 at 17:23