![]() |
Compatibility of custom HTML tags
I have a site where I use a JavaScript function to let the user increase font sizes in preselected areas. Those areas are currently denoted with a <p></p>.
Recently, I've come across the issue where user-generated content may include a <div> </div>, which then breaks the <p> tag. In retrospect, I don't really have very many tags that I can use that wouldnever be included in the user-generated content, so I'm giving thought to a custom HTML tag; something like <mydomain> </mydomain>, then apply the JavaScript function to that tag instead of <p> </p>. My question is, if I went that route, would the <mydomain> tag be compatible on all of the modern browsers (meaning, the last year or two)? Or am I going to run in to issues of certain browsers totally ignoring all content between the open and close, or worse, throwing an error? |
Re: Compatibility of custom HTML tags
jwcarlton@gmail.com wrote:
> I have a site where I use a JavaScript function to let the user increase font sizes in preselected areas. Those areas are currently denoted with a <p> </p>. > > Recently, I've come across the issue where user-generated content may include a <div> </div>, which then breaks the <p> tag. Breaks the <p> tag? Maybe a URL will be helpful for what you are trying to describe. If you mean placing a DIV within a P element, well that isn't valid. You can place a P with a DIV though. > > In retrospect, I don't really have very many tags that I can use that would never be included in the user-generated content, so I'm giving thought to a custom HTML tag; something like <mydomain> </mydomain>, then apply the JavaScript function to that tag instead of <p> </p>. > > My question is, if I went that route, would the <mydomain> tag be compatible on all of the modern browsers (meaning, the last year or two)? Or am I going to run in to issues of certain browsers totally ignoring all content between the open and close, or worse, throwing an error? > Not sure what you are trying to accomplish. Custom elements are not valid with HTML. To extend it your would need XHTML, Extensible HyperText Markup Language. But since MS never really "came on board" the XHTML bandwagon XHTML is really dead. You need to give more details of what you wish to do. -- Take care, Jonathan ------------------- LITTLE WORKS STUDIO http://www.LittleWorksStudio.com |
Re: Compatibility of custom HTML tags
In article <466d994f-a28c-4a24-b7c6-5ee076cca9a0@googlegroups.com>,
jwcarlton@gmail.com wrote: > I have a site where I use a JavaScript function to let the user increase font > sizes in preselected areas. Those areas are currently denoted with a <p> > </p>. > > Recently, I've come across the issue where user-generated content may include > a <div> </div>, which then breaks the <p> tag. > > In retrospect, I don't really have very many tags that I can use that would > never be included in the user-generated content, so I'm giving thought to a > custom HTML tag; something like <mydomain> </mydomain>, then apply the > JavaScript function to that tag instead of <p> </p>. > > My question is, if I went that route, would the <mydomain> tag be compatible > on all of the modern browsers (meaning, the last year or two)? Or am I going > to run in to issues of certain browsers totally ignoring all content between > the open and close, or worse, throwing an error? Why not just use a regular classed DIV instead of a P, at least, then, any inner DIV would be kosher. And if you were using P for its default styling (the browser provides a default style, usually via a hidden style sheet), nothing is easier to style the classed DIV replacement to be similar. There would be no particular browser issues with such simple things as bits of top or bottom margins and paddings. -- dorayme |
Re: Compatibility of custom HTML tags
In article <dorayme-17AB41.17353106092012@news.albasani.net>,
dorayme <dorayme@optusnet.com.au> wrote: er... > nothing is easier to style [than] the classed DIV replacement > to be similar to a P. -- dorayme |
Re: Compatibility of custom HTML tags
On Thursday, September 6, 2012 3:59:32 AM UTC-4, dorayme wrote:
> > nothing is easier to style [than] the classed DIV replacement > > > to be similar to a P. If I understand correctly, though, getElementByClassName (which would be necessary for this feature) isn't supported in IE7 or IE8. For this site, 51%of my traffic comes from IE, and 42% of that is IE7 or IE8, so I still have to worry about backwards compatibility :-( On the plus side, I only see 0.5% from IE6! LOL |
Re: Compatibility of custom HTML tags
On Thursday, September 6, 2012 12:05:31 AM UTC-4, Jonathan N. Little wrote:
> > Recently, I've come across the issue where user-generated content may include a <div> </div>, which then breaks the <p> tag. > > Breaks the <p> tag? Maybe a URL will be helpful for what you are trying > to describe. If you mean placing a DIV within a P element, well that > isn't valid. You can place a P with a DIV though. That's exactly what I meant. For example, if I have (in PHP): <p> $user_content </p> and the user submits something that includes <div>...</div>, then it's not valid. FWIW, I'm using a contenteditable field, so the user doesn't necessarily mean to include the tags; they're just being copied when they quote other sites. With the script that I'm using to change the font size of <p>, the embedded<div></div> ends the script. Anything in $user_content before the first <div> will be affected, but anything after is ignored. > > My question is, if I went that route, would the <mydomain> tag be compatible on all of the modern browsers (meaning, the last year or two)? Or am I going to run in to issues of certain browsers totally ignoring all content between the open and close, or worse, throwing an error? > > Not sure what you are trying to accomplish. Custom elements are not > valid with HTML. To extend it your would need XHTML, > Extensible HyperText Markup Language. But since MS never really "came on > board" the XHTML bandwagon XHTML is really dead. You need to give more > details of what you wish to do. Ahh, I didn't realize that. I recently came across the idea of a custom tagfrom WashingtonPost.com, but it does look like their doctype is XHTML 1.0 Transitional. What I'm really trying to do is find is a tag name that I could use to safely wrap $user_content, and that's obscure enough that the user will not be likely to submit content with it included. |
Re: Compatibility of custom HTML tags
2012-09-06 19:40, jwcarlton@gmail.com wrote:
> For example, if I have (in PHP): > > <p> > $user_content > </p> > > and the user submits something that includes <div>...</div>, then it's not valid. There are loads of tags that aren't valid within a <p> element. For example, <p>. Or, rather, a <p> tag implicitly closes an open <p> element and starts a new one. There should be no reason to use <p> here. Instead, use <div>, which allows anything that is valid inside <body>, and use class and/or id attributes to make it possible to refer to a specific <div> element. I would recommend using a semicryptic id, with a value that won't appear in the user data in practice. Say, <div id="jwcarlton@gmail.com-input">. > FWIW, I'm using a contenteditable field, so the user doesn't necessarily > mean to include the tags; they're just being copied when they quote other sites. Right. So they might contain <p>, <div>, and fancy classes and ids. > With the script that I'm using to change the font size of <p>, the embedded > <div></div> ends the script. Script? Changing font size does not need a script, just a little piece of CSS. And surely a <div> tag implicitly closes an open <p> element. This won't happen if your editable block is marked up as <div>. There's a catch, though. > I recently came across the idea of a custom tag from WashingtonPost.com, > but it does look like their doctype is XHTML 1.0 Transitional. That's rather irrelevant. XHTML on the web is parsed as HTML in reality. They do their daily tag slurping. But custom tags are not the solution here. -- Yucca, http://www.cs.tut.fi/~jkorpela/ |
Re: Compatibility of custom HTML tags
In article <7b44a27f-af30-4bb5-bdd4-621c54a70ab6@googlegroups.com>,
<jwcarlton@gmail.com> wrote: > >That's exactly what I meant. For example, if I have (in PHP): > ><p> > $user_content ></p> > >and the user submits something that includes <div>...</div>, then it's not valid. If you're letting the user submit un-vetted content, you've got worse problems than that. Sometimes when I encounter a site that I suspect is accepting user content without validating it first, I add an unclosed <blink> tag. Read this comic and get back to us: http://xkcd.com/327/ -- -Ed Falk, falk@despams.r.us.com http://thespamdiaries.blogspot.com/ |
Re: Compatibility of custom HTML tags
On Thursday, September 6, 2012 12:56:31 PM UTC-4, Jukka K. Korpela wrote:
> There are loads of tags that aren't valid within a <p> element. For > example, <p>. Or, rather, a <p> tag implicitly closes an open <p> > element and starts a new one. Good point. > There should be no reason to use <p> here. Instead, use <div>, which > allows anything that is valid inside <body>, and use class and/or id > attributes to make it possible to refer to a specific <div> element. I > would recommend using a semicryptic id, with a value that won't appear > in the user data in practice. Say, <div id="jwcarlton@gmail.com-input">.. Yes, but I'm using <div> tags heavily throughout the site, so I can't rely on it for this purpose. I'll explain more later in this post... > > With the script that I'm using to change the font size of <p>, the embedded > > <div></div> ends the script. > > Script? Changing font size does not need a script, just a little piece > of CSS. And surely a <div> tag implicitly closes an open <p> element. > This won't happen if your editable block is marked up as <div>. I apologize for not being more clear. I'm specifically using a JavaScript function to let the user increase font sizes in preselected areas, and currently those areas are denoted with a <p></p>. This gives the user the optionto zoom in on certain areas, without zooming in with their browser or negatively affecting other parts of the page. This is mostly used by less-savvy users that don't understand how to zoom with their browser, but do understand a section of the webpage that says "click here to make the text larger" :-) This is why I can't really use a <div> tag for this purpose. I'm using <div> tags for things like the logo, etc, and specifically don't want them to be affected by the script. And since there are multiple user posts that would be affected by the script, I can't rely on an id, either. |
Re: Compatibility of custom HTML tags
On Thursday, September 6, 2012 1:43:12 PM UTC-4, Edward A. Falk wrote:
> If you're letting the user submit un-vetted content, you've got worse > problems than that. LOL I'm not quite THAT naive! The content isn't "un-vetted" at all; in fact, it's been a rather cumbersome PITA to write a function to format all of the posts correctly. Removing unrecognized classes, relative images, CSS backgrounds and positions, etc... it's been a pain, trust me! Realistically, I do strip all HTML and JavaScript tags except for: div|p|a|span|font|img|br|b|u|i So if there's an HTML tag (except for a <table>, which I do use somewhat inother parts of the site) that I could use to wrap any/all of these tags without an error, then I could probably use it. |
| All times are GMT. The time now is 03:38 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.