wjw Posted June 19, 2006 Share Posted June 19, 2006 I'm looking for a way to add custom attributes to some of my elements (inputs and textareas). Is this possible with strict XHTML or do I have to create a new DTD? I'm not opposed to doing that, but am concerned with browser support.Any suggestions on how to do this and a discussion of the pros/cons of the various methods is greatly appreciated.Thanks Link to comment Share on other sites More sharing options...
boen_robot Posted June 19, 2006 Share Posted June 19, 2006 To create a new attribute and/or element in XHTML and still keep it valid, you'll need to create a new DTD.As for display... if it's an atribute, it shouldn't need a special kind of display. If it's something that should be rendered (an element to be more precise)... If the XHTML is served with the MIME type application/xhtml+xml, then the true XHTML rules apply, thus only real XHTML elements are rendered. Elements that were never part of any W3C's XHTML specification will be shown as plain text. If the XHTML is server with the MIME type text/html (as most probably is) then only XHTML, HTML and legacy HTML elements are rendered. Elements that were never part of any W3C or browser vendor's specification will be shown as plain text. In general, avoid creating custom elements. You have the wonderful IDs for targeting specific elements and the even more wonderful classes to target groups. Link to comment Share on other sites More sharing options...
wjw Posted June 19, 2006 Author Share Posted June 19, 2006 To create a new attribute and/or element in XHTML and still keep it valid, you'll need to create a new DTD.As for display...if it's an atribute, it shouldn't need a special kind of display. If it's something that should be rendered (an element to be more precise)... If the XHTML is served with the MIME type application/xhtml+xml, then the true XHTML rules apply, thus only real XHTML elements are rendered. Elements that were never part of any W3C's XHTML specification will be shown as plain text. If the XHTML is server with the MIME type text/html (as most probably is) then only XHTML, HTML and legacy HTML elements are rendered. Elements that were never part of any W3C or browser vendor's specification will be shown as plain text. <{POST_SNAPBACK}> The attributes I want to add are not for display purposes. An example would be an attribute named "helpmsg" which would be set to a value that is looked up in a javascript array to show context-sensitive help. I can create a map in javascript that will have the same effect, but it would be cleaner if there were an attribute on the element.Thanks for the info on the MIME type, I hadn't come across that yet. Link to comment Share on other sites More sharing options...
boen_robot Posted June 19, 2006 Share Posted June 19, 2006 Well, scince there is another way, you should use scripting. Just wait until XForms are supported. We would be living in a forms' paradise . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now