EllisLab text mark
Advanced Search
     
xHTML Helper
Posted: 18 November 2007 06:35 PM   [ Ignore ]
Avatar
Joined: 2007-07-30
2144 posts

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):

<?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>
    </
body>
</
html
 Signature 

Follow me on twitter here.
MichaelWales.com | MichaelWales.info

 
Posted: 18 November 2007 07:06 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2006-07-14
4237 posts

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.

 
Posted: 18 November 2007 08:12 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-07-30
2144 posts

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.

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.

 Signature 

Follow me on twitter here.
MichaelWales.com | MichaelWales.info

 
Posted: 18 November 2007 10:15 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2007-06-13
76 posts

Seems ok, i dont know id probably rather a view approach like have now.

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. raspberry