--- title: 'HTML' sidebar_label: Introduction description: 'The procedural macro for generating HTML and SVG' slug: /concepts/html --- import Tabs from '@theme/Tabs' import TabItem from '@theme/TabItem' The `html!` macro allows you to write HTML and SVG code declaratively. It is similar to JSX (an extension to JavaScript that allows you to write HTML-like code inside of JavaScript). **Important notes** 1. The `html!` macro only accepts one root html node (you can counteract this by using [fragments](./fragments.mdx) or [iterators](./../html/lists.mdx)) 2. An empty `html! {}` invocation is valid and will not render anything 3. Literals must always be quoted and wrapped in braces: `html! {

{ "Hello, World" }

}` 4. The `html!` macro will make all tag names lowercase. To use upper case characters (which are required for some SVG elements) use [dynamic tag names](concepts/html/elements.mdx#dynamic-tag-names): `html! { <@{"myTag"}> }` :::note The `html!` macro can reach the default recursion limit of the compiler. If you encounter compilation errors, add an attribute like `#![recursion_limit="1024"]` in the crate root to overcome the problem. ::: ## Tag Structure Tags are based on HTML tags. Components, Elements, and Lists are all based on this tag syntax. Tags must either self-close `<... />` or have a corresponding end tag for each start tag. ```rust use yew::prelude::*; html! {
}; ```
```rust ,compile_fail use yew::prelude::*; html! {
// <- MISSING CLOSE TAG }; ``` ```rust use yew::prelude::*; html! { }; ``` ```rust ,compile_fail use yew::prelude::*; html! { // <- MISSING SELF-CLOSE }; ``` :::tip For convenience, elements which _usually_ require a closing tag are **allowed** to self-close. For example, writing `html! {
}` is valid. ::: ## Children Create complex nested HTML and SVG layouts with ease: ```rust use yew::prelude::*; html! {