# perldoc > HTML::AsSubs

---
type: CommandReference
command: HTML::AsSubs
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference
- `use HTML::AsSubs;` — import all HTML tag functions
- `body(h1("Title"), p("Text"))` — construct a `<body>` with heading and paragraph
- `a({href=>'url'}, "link")` — anchor with attributes
- `img({src=>'img.gif', alt=>'image'})` — image element with attributes
- `print $h->as_HTML;` — output the HTML tree as a string
- `html(head(title("Page")))` — nested structure

## Name
`HTML::AsSubs` — functions that construct a HTML syntax tree

## Synopsis
perl
use HTML::AsSubs;
$h = body(
    h1("This is the heading"),
    p("This is the first paragraph which contains a ",
      a({href=>'link.html'}, "link"),
      " and an ",
      img({src=>'img.gif', alt=>'image'}),
      "."
    ),
);
print $h->as_HTML;
## Options
The module exports functions named after HTML tags (lowercase). If the first argument is a hash reference, it sets attributes; remaining arguments are content.

Commonly used functions:
- `html` — root element
- `head`, `body`, `title` — document structure
- `h1`, `h2`, `h3`, `h4`, `h5`, `h6` — headings
- `p`, `div`, `span`, `br`, `hr` — block/inline elements
- `a`, `img` — links and images
- `ul`, `ol`, `li`, `dl`, `dt`, `dd` — lists
- `table`, `tr`, `td`, `th`, `caption` — tables
- `form`, `input`, `select`, `option`, `textarea` — forms
- `script`, `style`, `link`, `meta` — head elements
- And many others: `base`, `blockquote`, `pre`, `code`, `em`, `strong`, `b`, `i`, `u`, `tt`, `big`, `small`, `sub`, `sup`, `dfn`, `cite`, `samp`, `kbd`, `var`, `address`, `font`, `center`, `strike`, `object`, `applet`, `param`, `map`, `area`, `frame`, `frameset`, `noframe`, `isindex`, `nextid`, `menu`, `dir`

Note: `link()` overrides Perl’s builtin `link`; `tr()` must be called as `&tr(...)` due to the builtin `tr///` operator.

## Examples
perl
# Simple document
print html(
    head(title("My Page")),
    body(
        h1("Welcome"),
        p("Some text.")
    )
)->as_HTML;

# Attributes via hashref
print div({id => "main", class => "container"}, "Content")->as_HTML;
## See Also
- [HTML::Element](perldoc/HTML::Element)
- [XML::Generator](perldoc/XML::Generator)