This PHP class provides a convenient way to generate HTML elements with attributes and child elements. It supports creating a variety of HTML tags and setting attributes using a fluent interface.
-
Include the
HtmlElementclass in your PHP code. -
Create an instance of the
HtmlElementclass to generate HTML elements. -
Use the various methods provided by the class to set attributes, add child elements, and modify properties.
-
Output the generated HTML using the
output()method.
// Create an HTML element
$html = new HtmlElement('div');
$html->setId('myDiv')->setClass('some-class');
// Add child elements and modify them
$html->add_child('MainTitle','h1')->text('Hello, World!')->setClass('title');
// Modify the child element using a fluent interface
$html->MainTitle->setStyle('color: blue;');
// Output the HTML
echo $html->output();- Finish the implementation of all html tags.
- Add support for HTMX.
- Add support for Hyperscript.
- Add suport for Css frameworks like bootstrap or tailwind.