CodeIgniter Forums
xHTML Helper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: xHTML Helper (/thread-4331.html)



xHTML Helper - El Forum - 11-18-2007

[eluser]Michael Wales[/eluser]
I'm always hitting Google to remember the syntax of the DOCTYPE declaration - or what the URL is to W3C's HTML namespace. So, I decided to whip up a quick little helper to assist in this - check it out on the Wiki (xHTML Helper).

If you are an HTML 4 kind of person, this helper will still prove useful as it includes doctype declarations for HTML 4, xHTML 1.0, and xHTML 1.1 (with error handling, in case you define an illegal pairing between language and DTD).

If you use xHTML 1.0 or xHTML 1.1 (like the rest of the sane development community) - you can also make use of the html function, which outputs a valid HTML tag with namespace defaulting to W3C's namespace, and the contentType function, which outputs a valid META tag declaring the Content-Type (defaulting to UTF-8).

Hope this makes someone's life easier - here's a quick snippet, where it's all put together (with a touch of my asset helper):

Code:
<?= xhtml_doctype(); ?>
<?= xhtml_html(); ?>
    <head>
        <?= xhtml_contentType(); ?>
        <?= css_asset('style.css'); ?>
        <title>MichaelWales.com</title>
    </head>
    <body>
        <div id="wrapper">
            <h1>MichaelWales.com</h1>
        </div>
    &lt;/body&gt;
&lt;/html&gt;



xHTML Helper - El Forum - 11-18-2007

[eluser]xwero[/eluser]
If you set up your templates for creating new files in your editor don't you add the doctype? I think this is an overuse of php.

I don't know how sane the development community is but i'm not so sure if xhtml is the only right way to go judging by the current events in html versions. I think html 5 will see the light before xhtml 2.

This is my personal opinion not a personal attack so i hope you don't see it like that.


xHTML Helper - El Forum - 11-18-2007

[eluser]Michael Wales[/eluser]
Quote:If you set up your templates for creating new files in your editor don’t you add the doctype? I think this is an overuse of php.

I don't use any sort of editor (other than a text editor) so it works out for me.

Quote:I don’t know how sane the development community is but i’m not so sure if xhtml is the only right way to go judging by the current events in html versions. I think html 5 will see the light before xhtml 2.

This is my personal opinion not a personal attack so i hope you don’t see it like that.

I haven't looked into HTML 2 that much yet but it could definitely be a game changer. XHTML is the way to go with the current state of development though.


xHTML Helper - El Forum - 11-18-2007

[eluser]schnoodles[/eluser]
Seems ok, i dont know id probably rather a view approach like have now.

Quote:If you use xHTML 1.0 or xHTML 1.1 (like the rest of the sane development community)
I thought you only use that if you use XSLT. Tongue