Heres a great article about saying hello to the world. only the way everybody else does it -- by saying hello world... only in latin...
qHTML is a simplified, custom representation of HTML designed for ease of reading and maintenance; its syntax resembles CSS but defines HTML structure and attributes inline. Because qHTML is implemented as a custom web component, you simply wrap your markup in a <q-html>
element and it will transform into standard HTML without any boilerplate or JavaScript API. It’s also easy to extend by defining new custom components so you can reuse blocks with custom attributes.
A qHTML document looks like CSS: you write tag names followed by braces, and inside the braces you specify attributes and nested elements. Attributes are assigned using name: "value"
pairs, and the content
property (or synonyms like text
or innertext
) sets the inner text of an element. All valid HTML attributes work, including event handlers like onclick
, and you can nest elements by declaring additional blocks inside braces.
For example:
<script src="qhtml.js"></script>
<q-html>
div {
id: "myDiv"
class: "container"
content: "click the button below for a special message"
button {
onclick: "alert('hello world')"
content: "click me!"
}
}
</q-html>
When the page loads, the qHTML component generates the equivalent HTML:
<div id="myDiv" class="container">
click the button below for a special message
<button onclick="alert('hello world')">click me!</button>
</div>
qHTML also includes optional helpers like simplified nesting (write multiple tags separated by commas), custom components defined with <q-component>
, and a <q-script>
tag for adding event listeners in a concise syntax.
Check out the examples below for a couple of exmaples of features available in qHTML.
<q-html>
tag and it renders automatically.<q-component>
and they become available with all their inline attributes.<q-script>
tag to attach event listeners and write small scripts using CSS selector syntax.prerequisites: q-html.js, w3.css
prerequisites: q-html.js, w3-tags.js
q-component { id: "nav-button" w3-bar-item,w3-black,w3-btn,w3-hover-blue,span { slot { name: "button-contents"; } html { ➡️ } } } w3-main,w3-green,div { w3-bar-block,w3-grey,div { nav-button { span { slot: "button-contents" html { button 1 } } } nav-button { span { slot: "button-contents" html { button 2 } } } nav-button { span { slot: "button-contents" html { button 3 } } } } }
prerequisites: qhtml.js, w3-tags.js
Combine unlimited numbers of w3-tags with plain html tags to create complex layouts
Everytime you combine two or more tags (separating them with a comma) , it creates a nested structure.
div,span,div { }
is equivalent to
<div> <span> <div> </div> </span> </div>
w3-tags.js creates a uniqe custom element definition for each of the w3-* CSS classes from the w3.css framework.
When you use the custom element tags, the result will be like this.
w3-main,w3-green,div { } w3-main,w3-green,div,w3-blue,div { }
is equivalent to
<w3-main> <w3-green> <div> </div> </w3-green> </w3-main> <w3-main> <w3-green> <div> <w3-blue> <div> </div> </w3-blue> </div> </w3-green> </w3-main>
Now w3-tags.js will transform nested w3-elements into their equivalent classes and apply them to the next non w3-element that appears in the hierarchy.
The above translates into this when all is said and done:
<div class="w3-main w3-green"> </div> <div class="w3-main w3-green"> <div class="w3-blue"> </div> </div>
Heres a great article about saying hello to the world. only the way everybody else does it -- by saying hello world... only in latin...
Heres a great article about saying hello to the world. only the way everybody else does it -- by saying hello world... only in latin...
prerequisites: qhtml.js, w3-tags.js (or bs-tags.js)
When you use bs-tags (bootstrap tags) or w3-tags (w3.css tags), the w3-* and bs-* HTML tags support a way to pass along a set of classes to all of the direct descendants of a chain of tags.
If you do not terminate a chain of w3-tags or bs-tags by putting a final regular HTML element at the end of the chain, but instead begin a block using the brackets. { }, Everything inside of the brackets will be treated as if it is the last part of the chain, whether that part is a regular HTML element or additional w3-tags (or bs-tags).
You can nest multiple unterminated chains to create complex CSS rules.
w3-green,w3-large { w3-button,w3-hover-blue { w3-bar,span { text: "hello" } w3-bar,span { text: "world" } } }
Since there is no terminating HTML element for the first two nested chains, w3-tags will apply both of the chains to each span separately