Skip to main content
Dioxus provides a comprehensive set of HTML elements that can be used with the rsx! macro. All elements are type-safe and come with comprehensive documentation.

Document Metadata

base

The <base> element specifies the base URL to use for all relative URLs in a document.
rsx! {
    base { href: "https://example.com/", target: "_blank" }
}
Attributes: href, target Reference: MDN The <head> element contains machine-readable information (metadata) about the document.
rsx! {
    head {
        title { "My App" }
        meta { charset: "utf-8" }
    }
}
Reference: MDN The <link> element specifies relationships between the current document and an external resource.
rsx! {
    link { 
        rel: "stylesheet", 
        href: "/styles.css",
        r#type: "text/css"
    }
}
Attributes: href, rel, type, crossorigin, hreflang, media, sizes, title, integrity, disabled, referrerpolicy, fetchpriority, blocking, as Reference: MDN

meta

The <meta> element represents metadata that cannot be represented by other HTML meta-related elements.
rsx! {
    meta { charset: "utf-8" }
    meta { name: "viewport", content: "width=device-width, initial-scale=1" }
    meta { property: "og:title", content: "My App" }
}
Attributes: charset, content, http_equiv, name, property Reference: MDN

style

The <style> element contains style information for a document.
rsx! {
    style { r#type: "text/css", ".my-class {{ color: red; }}" }
}
Attributes: type, media, nonce, title Reference: MDN

title

The <title> element defines the document’s title shown in the browser’s title bar or page tab.
rsx! {
    title { "My Page Title" }
}
Reference: MDN

Sectioning Root

body

The <body> element represents the content of an HTML document.
rsx! {
    body {
        h1 { "Welcome" }
        p { "Content here" }
    }
}
Reference: MDN

Content Sectioning

address

The <address> element indicates contact information for a person or organization.
rsx! {
    address {
        "Contact us at: "
        a { href: "mailto:[email protected]", "[email protected]" }
    }
}
Reference: MDN

article

The <article> element represents a self-contained composition in a document.
rsx! {
    article {
        h2 { "Article Title" }
        p { "Article content..." }
    }
}
Reference: MDN

aside

The <aside> element represents content tangentially related to the content around it.
rsx! {
    aside {
        h3 { "Related Links" }
        ul { li { "Link 1" } }
    }
}
Reference: MDN The <footer> element represents a footer for its nearest sectioning content or root element.
rsx! {
    footer {
        p { "© 2024 My Company" }
    }
}
Reference: MDN The <header> element represents introductory content, typically a group of introductory or navigational aids.
rsx! {
    header {
        h1 { "Site Title" }
        nav { /* navigation */ }
    }
}
Reference: MDN

h1, h2, h3, h4, h5, h6

The heading elements represent six levels of section headings.
rsx! {
    h1 { "Main Heading" }
    h2 { "Subheading" }
    h3 { "Sub-subheading" }
}
Reference: MDN - h1

main

The <main> element represents the dominant content of the document body.
rsx! {
    main {
        article { "Main content" }
    }
}
Reference: MDN The <nav> element represents a section of navigation links.
rsx! {
    nav {
        a { href: "/home", "Home" }
        a { href: "/about", "About" }
    }
}
Reference: MDN

section

The <section> element represents a generic standalone section of a document.
rsx! {
    section {
        h2 { "Section Title" }
        p { "Section content" }
    }
}
Reference: MDN

Text Content

blockquote

The <blockquote> element indicates that the enclosed text is an extended quotation.
rsx! {
    blockquote { cite: "https://example.com", "Quote text" }
}
Attributes: cite Reference: MDN

div

The <div> element is a generic container for flow content.
rsx! {
    div { class: "container",
        p { "Content inside div" }
    }
}
Reference: MDN

dl, dt, dd

Description list elements for term-description pairs.
rsx! {
    dl {
        dt { "Term" }
        dd { "Definition" }
    }
}
Reference: MDN - dl

figcaption

The <figcaption> element represents a caption or legend for a figure.
rsx! {
    figure {
        img { src: "/image.jpg" }
        figcaption { "Image caption" }
    }
}
Reference: MDN

figure

The <figure> element represents self-contained content, potentially with an optional caption. Reference: MDN

hr

The <hr> element represents a thematic break between content.
rsx! {
    p { "Section 1" }
    hr {}
    p { "Section 2" }
}
Reference: MDN

li

The <li> element represents an item in a list.
rsx! {
    ul {
        li { "Item 1" }
        li { "Item 2" }
    }
}
Attributes: value (for ordered lists) Reference: MDN

ol

The <ol> element represents an ordered list of items.
rsx! {
    ol { reversed: true, start: 10,
        li { "First" }
        li { "Second" }
    }
}
Attributes: reversed, start, type Reference: MDN

p

The <p> element represents a paragraph.
rsx! {
    p { "This is a paragraph." }
}
Reference: MDN

pre

The <pre> element represents preformatted text.
rsx! {
    pre { "Preformatted\n  text" }
}
Reference: MDN

ul

The <ul> element represents an unordered list of items.
rsx! {
    ul {
        li { "Item 1" }
        li { "Item 2" }
    }
}
Reference: MDN

Inline Text Semantics

a

The <a> element creates a hyperlink.
rsx! {
    a { href: "https://example.com", target: "_blank", "Link text" }
}
Attributes: download, href, hreflang, target, type, ping, rel Reference: MDN

abbr

The <abbr> element represents an abbreviation or acronym.
rsx! {
    abbr { title: "HyperText Markup Language", "HTML" }
}
Reference: MDN

b

The <b> element draws attention to text without indicating extra importance.
rsx! {
    b { "Bold text" }
}
Reference: MDN

br

The <br> element produces a line break.
rsx! {
    p {
        "Line 1"
        br {}
        "Line 2"
    }
}
Reference: MDN

code

The <code> element displays text as computer code.
rsx! {
    code { "let x = 42;" }
}
Attributes: language Reference: MDN

em

The <em> element marks text with stress emphasis.
rsx! {
    em { "Emphasized text" }
}
Reference: MDN

i

The <i> element represents text in an alternate voice or mood.
rsx! {
    i { "Italic text" }
}
Reference: MDN

kbd

The <kbd> element represents keyboard input.
rsx! {
    kbd { "Ctrl" } "+" kbd { "C" }
}
Reference: MDN

mark

The <mark> element represents highlighted text.
rsx! {
    mark { "Highlighted text" }
}
Reference: MDN

small

The <small> element represents side comments and fine print.
rsx! {
    small { "Fine print" }
}
Reference: MDN

span

The <span> element is a generic inline container.
rsx! {
    span { class: "highlight", "Highlighted" }
}
Reference: MDN

strong

The <strong> element indicates strong importance.
rsx! {
    strong { "Important text" }
}
Reference: MDN

time

The <time> element represents a specific period in time.
rsx! {
    time { datetime: "2024-03-04", "March 4, 2024" }
}
Attributes: datetime Reference: MDN

Image and Multimedia

audio

The <audio> element embeds sound content.
rsx! {
    audio { controls: true, src: "/audio.mp3" }
}
Attributes: autoplay, controls, crossorigin, muted, preload, src, loop Reference: MDN

img

The <img> element embeds an image.
rsx! {
    img { 
        src: "/image.jpg", 
        alt: "Description",
        width: 300,
        height: 200
    }
}
Attributes: alt, crossorigin, decoding, height, ismap, loading, src, srcset, usemap, width, referrerpolicy, sizes, fetchpriority Reference: MDN

video

The <video> element embeds video content.
rsx! {
    video { 
        controls: true,
        width: 640,
        height: 360,
        src: "/video.mp4"
    }
}
Attributes: autoplay, controls, crossorigin, height, loop, muted, preload, playsinline, poster, src, width Reference: MDN

Embedded Content

iframe

The <iframe> element embeds another HTML page.
rsx! {
    iframe { 
        src: "https://example.com",
        width: 800,
        height: 600,
        allow: "fullscreen"
    }
}
Attributes: allow, allowfullscreen, allowpaymentrequest, height, name, referrerpolicy, src, srcdoc, width Reference: MDN

Scripting

canvas

The <canvas> element provides a drawing surface.
rsx! {
    canvas { width: 800, height: 600 }
}
Attributes: width, height Reference: MDN

script

The <script> element embeds executable code.
rsx! {
    script { src: "/script.js", r#async: true }
}
Attributes: src, type, async, defer, crossorigin, integrity, nomodule, nonce, referrerpolicy, fetchpriority Reference: MDN

Table Content

table

The <table> element represents tabular data.
rsx! {
    table {
        thead {
            tr {
                th { "Header 1" }
                th { "Header 2" }
            }
        }
        tbody {
            tr {
                td { "Cell 1" }
                td { "Cell 2" }
            }
        }
    }
}
Reference: MDN

thead, tbody, tfoot

Table section elements for header, body, and footer. Reference: MDN - thead

tr

The <tr> element defines a row of table cells. Reference: MDN

th

The <th> element defines a header cell in a table.
rsx! {
    th { scope: "col", "Header" }
}
Attributes: abbr, colspan, rowspan, scope Reference: MDN

td

The <td> element defines a data cell in a table.
rsx! {
    td { colspan: 2, "Cell content" }
}
Attributes: colspan, rowspan Reference: MDN

Forms

form

The <form> element represents a document section containing interactive controls.
rsx! {
    form { 
        action: "/submit",
        method: "post",
        input { r#type: "text", name: "username" }
        button { r#type: "submit", "Submit" }
    }
}
Attributes: action, autocomplete, enctype, method, name, novalidate, target Reference: MDN

button

The <button> element represents a clickable button.
rsx! {
    button { 
        r#type: "button",
        onclick: |_| println!("Clicked!"),
        "Click me"
    }
}
Attributes: autofocus, disabled, form, formaction, formenctype, formmethod, formnovalidate, formtarget, name, type, value Reference: MDN

input

The <input> element creates interactive controls for forms.
rsx! {
    input {
        r#type: "text",
        name: "username",
        placeholder: "Enter username",
        value: "{username}",
        oninput: move |e| username.set(e.value())
    }
}
Attributes: accept, alt, autocomplete, autofocus, capture, checked, disabled, form, height, list, max, maxlength, min, minlength, multiple, name, pattern, placeholder, readonly, required, size, src, step, type, value, width Input Types: button, checkbox, color, date, datetime-local, email, file, hidden, image, month, number, password, radio, range, reset, search, submit, tel, text, time, url, week Reference: MDN

label

The <label> element represents a caption for a form control.
rsx! {
    label { r#for: "username", "Username:" }
    input { id: "username", r#type: "text" }
}
Attributes: for, form Reference: MDN

select

The <select> element represents a control for selecting among options.
rsx! {
    select { 
        name: "choice",
        onchange: move |e| selection.set(e.value()),
        option { value: "1", "Option 1" }
        option { value: "2", "Option 2" }
    }
}
Attributes: autocomplete, autofocus, disabled, form, multiple, name, required, size, value Reference: MDN

option

The <option> element represents an option in a select element.
rsx! {
    option { value: "1", selected: true, "Choice 1" }
}
Attributes: disabled, label, selected, value Reference: MDN

textarea

The <textarea> element represents a multi-line plain text editing control.
rsx! {
    textarea {
        name: "message",
        rows: 5,
        cols: 40,
        placeholder: "Enter your message",
        value: "{message}",
        oninput: move |e| message.set(e.value())
    }
}
Attributes: autocomplete, autofocus, cols, disabled, form, maxlength, minlength, name, placeholder, readonly, required, rows, spellcheck, wrap, value Reference: MDN

fieldset

The <fieldset> element groups related form controls.
rsx! {
    fieldset {
        legend { "Personal Information" }
        input { r#type: "text", name: "name" }
    }
}
Attributes: disabled, form, name Reference: MDN

legend

The <legend> element represents a caption for a fieldset. Reference: MDN

progress

The <progress> element displays a progress indicator.
rsx! {
    progress { value: 70, max: 100 }
}
Attributes: max, value Reference: MDN

Interactive Elements

details

The <details> element creates a disclosure widget.
rsx! {
    details { open: true,
        summary { "Click to expand" }
        p { "Hidden content" }
    }
}
Attributes: open Reference: MDN

summary

The <summary> element specifies a summary for a details element. Reference: MDN

dialog

The <dialog> element represents a dialog box or modal.
rsx! {
    dialog { open: true,
        p { "This is a dialog" }
        button { "Close" }
    }
}
Attributes: open Reference: MDN

Web Components

slot

The <slot> element is a placeholder in a web component.
rsx! {
    slot { name: "content" }
}
Attributes: name Reference: MDN

template

The <template> element holds HTML that should not be rendered immediately. Reference: MDN

SVG

svg

The <svg> element is a container for SVG graphics.
rsx! {
    svg { 
        width: "100",
        height: "100",
        circle { cx: "50", cy: "50", r: "40", fill: "red" }
    }
}
Reference: MDN For more SVG elements like circle, rect, path, etc., see the SVG specification.

Element Usage

All elements follow the same pattern in rsx!:
rsx! {
    element_name {
        // Attributes first
        attribute_name: "value",
        another_attribute: true,
        
        // Then children
        "Text content"
        child_element {}
    }
}

See Also

Build docs developers (and LLMs) love