HTML 5 charset

webteam's Avatar

webteam

01 Nov, 2011 09:55 PM

If I try this: <meta charset="utf-8"> Cascade doesn't like it.

I found this works in Cascade: <meta content="text/html; charset=utf-8"/>

But I would prefer to follow the spec if possible. Also, it seems Cascade will try and close the meta tag no matter what. Is this a bug or am I missing something?

  1. 1 Posted by Charlie Holder on 01 Nov, 2011 10:03 PM

    Charlie Holder's Avatar

    What exactly do you mean by "Cascade doesn't like it?" Are you receiving an error or simply that your Template code is being jumbled?

    I apologize if this seems basic and I don't mean it in any way, but have you tried your code as a self-closing tag (like the working meta you posted)? That particular tag requires a slash at the end of it and Cascade also requires valid XML markup in the Templates.

    Does this achieve a desired output?
    <meta charset="utf-8"/>

  2. 2 Posted by webteam on 22 Nov, 2011 04:21 PM

    webteam's Avatar

    That does work in Cascade but it seems to have varying results in browsers using the charset reference closed that way (could be related to something other than the charset but that is what I am thinking now). I tried putting an unclosed charset wrapped in a system-view:external tag but Cascade still rewrote it as a closed tag. Trying to use an open charset inside of Cascade removed all HTML 5 tags (article, section, etc.). So I am wondering if there is a work-around I haven't thought of for getting the unclosed tag as the output but leaving it closed in Cascade? If not, maybe it is something you could look at for the next version.

  3. 3 Posted by Michael McGinni... on 21 Jan, 2012 11:06 AM

    Michael McGinnis's Avatar

    The varying results in browsers is surely caused by varying support for HTML5. Closing the charset reference is valid (X)HTML5. You shouldn't feel compelled to use invalid XML on your pages, especially since it's required in Cascade. What DOCTYPE are you using? What MIME or Content-type header value are you serving: text/html or application/xhtml+xml?

    We're using HTML5, and it validates on validator.nu, but it's going to have to be the XHTML version of HTML5 - I'm not going to try to fight it.

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/>

  4. 4 Posted by webteam on 23 Jan, 2012 03:01 PM

    webteam's Avatar

    I agree much of how things react in various user agents is related to the support of HTML5 in each agent. So, my hunt is for the most reliable set of code and hope the browsers will implement what the W3C is recommending.
    As for the strange results I found in Cascade, I think this was the result of a few things happening at the same time. I have successfully placed and published HTML5 tags so that isn't an issue as I originally thought. What I found is when saving a template, at times, Cascade will rewrite the code and move the head and body tags to a new location in the code. At that time it will remove any HTML5 specific tags. When this first happened I didn't notice that the head and body tags were moved. All I saw at first glance was the HTML 5 tags being stripped. At second glance it became apparent what happened and how the two were related. I have not pinned down just what causes this code rewrite. One example was the charset tag mentioned in my original post but there seems to be other times when this happens. My guess is malformed xml somewhere in the template. Perhaps valid html when the page is finally published but not valid in the template itself. Maybe the H-H folks have something to add?

  5. 5 Posted by Michael McGinni... on 23 Jan, 2012 04:09 PM

    Michael McGinnis's Avatar

    Yes, I think it must be malformed xml somewhere in the template. When I reported a similar problem with code being moved and rewritten, Joel at H-H referred me to https://hannonhill.jira.com/browse/CSI-109. Adam explains that "Cascade uses a utility called JTidy to fix invalid XHTML." The short explanation is that it's not enough to have valid HTML5 in the template or even in the published page. Templates may not contain any malformed XML, even though the HTML5 spec allows it. You have to use XHTML5.

  6. 6 Posted by webteam on 23 Jan, 2012 04:39 PM

    webteam's Avatar

    The only problem I have with the explanation of malformed xml is that the system should report it as such on save, thus letting you know you need to fix something before rewriting your code. This does happen at times so it makes me wonder if this isn't a bug based on certain specific code situations. Now what are those situations so we can avoid them, I don't know.

    Abotu Tidy, there is no check box for turning Tidy off on templates. Have I missed this somewhere. I know how to add/remove the option of using Tidy for pages in the system but not for templates. The option of not using Tidy on templates would be good if it is in fact applied behind the scenes to them.

    Here is what I am using currently and it seems to be safe:
    <!DOCTYPE html>

    <html lang="en">

    <head>

    <meta charset="utf-8"/>

    </head>

  7. 7 Posted by Michael McGinni... on 03 Feb, 2012 09:03 PM

    Michael McGinnis's Avatar

    I should emphasize that having my templates rewritten without notification is disturbing to me as well. I've finally learned to keep a copy of my original template as a text file, so I can paste it back, over and over, every time that JTidy silently strips out ALL the new HTML5 tags. That behavior affects my page structure, you know, adversely. Eventually I figure out what part of my code isn't valid XML. Recently I found another useful technique: save my template as an XML file and run it through a validator. That way, I can find the errors that JTidy is finding but isn't telling me about. (PS. This thread is attracting spammers.)

  8. 8 Posted by Charlie Holder on 19 Mar, 2012 08:04 PM

    Charlie Holder's Avatar

    Trying to follow up with some of the posts.

    Sounds like you've been able to get it working. I can comment on a few of the things mentioned here:

    Currently we aren't allowing to turn off JTidy for submitting Templates. Correct Michael -- We only use JTidy in the Template on invalid XHTML because we can't store an invalid template.

    If you're experiencing more issues trying to get these tags working, please let me know. You can certainly open this thread again or start a new one.

  9. Charlie Holder closed this discussion on 19 Mar, 2012 08:04 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac