Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (20.3k points)

Can I add a custom attribute to an HTML tag like the following?

<tag myAttri="myVal" />

1 Answer

0 votes
by (40.7k points)

You can just add in your !DOCTYPE declaration (i.e. DTD) to allow it, so that the [XML] document will still be valid like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

[

  <!ATTLIST tag myAttri CDATA #IMPLIED>

]>

 Here, #IMPLIED means it is an optional attribute, or you can just use #REQUIRED.

For more information, you can refer to https://www.w3schools.com/xml/xml_dtd_attributes.asp 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Aug 18, 2020 in Web Technology by Sudhir_1997 (55.6k points)

Browse Categories

...