head¶

class domilite.tags.head(*args: str | dom_tag | Markup, **kwargs: str | bool)[source]¶

Bases: html_tag

The <head> HTML element contains machine-readable information (metadata) about the document, like its title, scripts, and style sheets. There can be only one <head> element in an HTML document.

Attributes Summary

aria

A helper for accessing attributes of the form aria- for accessibility.

attributes

The attributes associated with this tag.

children

The list of child tags or markup objects

classes

The (HTML) classes associated with this tag, managed as a set of strings.

data

A helper for accessing attributes of the form data- as often used by client JS libraries.

flags

Rendering flags for this tag.

hx

A helper for accessing attributes of the form hx- for htmlx.

name

The name of this tag, inferred from the name of the class

Methods Summary

add(*children)

Add child tags to this tag.

clear()

Remove all chilren.

descendants()

Iterate over all children and children of children recursively.

find_tag_type(name)

Find a particular subclass of this tag with a given name.

iter_subclasses()

Iterate through all known subclasses of this tag, recursively.

remove(child)

Remove a particular child.

render([indent, flags, pretty, xhtml])

Render this tree of tags to a string.

Attributes Documentation

aria: PrefixAccessor['html_tag']¶

A helper for accessing attributes of the form aria- for accessibility. The aria- prefix is not required on this attribute.

attributes: ClassVar[AttributesProperty['dom_tag']]¶

The attributes associated with this tag. See Attributes for more details.

children: list['dom_tag | Markup']¶

The list of child tags or markup objects

classes¶

The (HTML) classes associated with this tag, managed as a set of strings. See Classes for more details.

data: PrefixAccessor['html_tag']¶

A helper for accessing attributes of the form data- as often used by client JS libraries. The data- prefix is not required on this attribute.

flags: ClassVar['Flags'] = 2¶

Rendering flags for this tag.

hx: PrefixAccessor['html_tag']¶

A helper for accessing attributes of the form hx- for htmlx. The hx- prefix is not required on this attribute.

name: Name = 'head'¶

The name of this tag, inferred from the name of the class

Methods Documentation

add(*children: dom_tag | str | Markup) → Self¶

Add child tags to this tag.

Parameters:

children (tag, string, or Markup) – Tags become children, strings are escaped, and Markup is text that is added raw to this tag.

Returns:

self

Return type:

this tag, to facilitate method chaining

clear() → Self¶

Remove all chilren.

Returns:

self

Return type:

this tag, to facilitate method chaining

descendants() → Iterator[dom_tag]¶

Iterate over all children and children of children recursively.

classmethod find_tag_type(name: str) → type[Self] | None¶

Find a particular subclass of this tag with a given name.

classmethod iter_subclasses() → Iterator[type[Self]]¶

Iterate through all known subclasses of this tag, recursively.

remove(child: dom_tag | Markup) → Self¶

Remove a particular child. If you are removing a string, escape it first with Markup.escape().

Parameters:

child (tag or Markup) – Child to remove. If it doesn’t exist, an error will be raised.

Returns:

self

Return type:

this tag, to facilitate method chaining

render(indent: str = '  ', flags: ~domilite.render.RenderFlags = <RenderFlags.PRETTY: 1>, pretty: bool | None = None, xhtml: bool | None = None) → str¶

Render this tree of tags to a string.

Parameters:
  • indent (str, optional) – String to use for indenting in pretty mode. Defaults to two spaces: ` `

  • flags (RenderFlags) – Adjust the rendering properties to use (e.g. turn off PRETTY)

  • pretty (bool or None) – Explicitly enable or disable pretty rendering.

  • xhtml (bool or None) – Explicitly enable or disable xhtml rendering.

Domilite

Navigation

Contents:

  • Getting Started
  • API Reference
    • domilite.dom_tag Module
    • domilite.tags Module
    • domilite.svg Module
    • domilite.util Module
    • domilite.template Module
  • Internals

Related Topics

  • Documentation overview
    • API Reference
      • Previous: html
      • Next: title
©. | Powered by Sphinx 8.2.3 & Alabaster 1.0.0 | Page source