Simple HTML wrapper class for PHP.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


HTML Helper is a complete PHP class which provide a really simple markup which will make your HTML rendering easier than ever.


Feel free to contact me via Email anytime you want. If you like this class and use it in somewhere, please, send me a feedback with your opinion about my job.

Fork it!

Please fork this project and help me with the development, I appreciate! =)


// Just include the class and you're ready to rock! :)
include_once(dirname(__FILE__) . '/class.html.php');

The $attributes variable

This variable can be a string like this: 'attribute1="value1" attribute2="value2"'. Or an array like this: array('attribute1' => 'value1', 'attribute2' => 'value2');. So when you're going to set the $attributes variable in some function, always remember the style of code that it must to be.



Return the specified doctype

// The below line will print the default doctype, which is HTML5: <!DOCTYPE html>
echo HTML::Doctype();

Available Doctypes

html5           -> HTML5
xhtml11         -> (x)HTML 1.1
xhtml1-strict   -> (x)HTML 1.0 Strict
xhtml1-trans    -> (x)HTML 1.0 Transitional
xhtml1-frame    -> (x)HTML 1.0 Frameset
html4-strict    -> HTML4 Strict
html4-trans     -> HTML4 Transitional
html4-frame     -> HTML4 Frameset


Returns the <img /> tag

// The below line will print: <img src="" border="0" />
echo HTML::Image('');


Returns the <a></a> with the specified attributes.

// The below line will print: <a href="" target="_blank" title="Visit Lunnaly's Website">Lunnaly</a>
echo HTML::Anchor('', 'Lunnaly', array('target' => '_blank', 'title' => 'Visit Lunnaly\'s Website'));


Returns a formated 'mailto' link.

// The below line will print: <a href="">My Email</a>
echo HTML::Email('', 'My Email');

Line break

Returns the <br /> (break) tag.

// The below line will print <br /><br /><br /> (3 times <br />)
echo HTML::LineBreak(3);


Returns the &nbsp; (white space) entity .

// The below line will print &nbsp;&nbsp;&nbsp; (3 times &nbsp;)
echo HTML::Space(3);


Create the structure following: <form>$fields</form>.

// The below line will print a 'post' form with the following 'action' attribute: 'my-file.php' and 2 fields which are: 'username' and 'password'.
echo HTML::Form('my-file.php', array('text' => array('id' => 'username', 'name' => 'username', 'placeholder' => 'I\'m a text field! =)'), 'password' => array('id' => 'password', 'name' => 'password', 'placeholder' => 'I\'m a password input! =)')));

HTML::Form() Usage

echo HTML::Form(the 'action' file, an array with the following structure: type => array(attribute => value));
That's all you need to print a form. =)

Open & Close

Open a tag and pass the specified attributes to the same.

// The below line will print an opened tag
echo HTML::Open('tag', 'attribute="value"');
echo 'My content goes here';
// After you've done inserting the content, you must close the tag.
echo HTML::Close();


Return the script version (major.minor.release)

// Usage
echo HTML::Version();