HTMLHeadElement

HTMLHeadElement

Overview

HTMLHeadElement is a class in Aspose.Html FOSS for Python. Inherits from: HTMLElement.

HTML <head> element (structural subclass).

This class provides 78 methods for working with HTMLHeadElement objects in Python programs. Available methods include: __init__, add_event_listener, after, append, append_child, attach_shadow, before, blur, check_visibility, click, clone_node, closest, and 66 additional methods. All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package. Properties: access_key, access_key_label, assigned_slot, attributes, autocapitalize, autofocus, and 64 more.

Properties

NameTypeAccessDescription
hiddenboolRead/WriteWhether the element is hidden (reflects the hidden boolean attribute).
titlestrRead/WriteThe tooltip title of this element (reflects the title attribute).
langstrRead/WriteThe language of the element’s content (reflects the lang attribute).
tab_indexintRead/WriteThe tab order index of this element (reflects the tabindex attribute).
access_keystrRead/WriteThe keyboard shortcut key for this element (reflects the accesskey
    attribute). |

| content_editable | str | Read/Write | Reflects the contenteditable attribute (WHATWG HTML §6.6). | | is_content_editable | bool | Read | Whether this element is currently editable (WHATWG HTML §6.6). | | dir | str | Read/Write | Text directionality of the element (reflects the dir attribute). | | draggable | bool | Read/Write | Whether the element is draggable (reflects the draggable attribute). | | spell_check | bool | Read/Write | Whether spellchecking is enabled (reflects the spellcheck attribute). | | spellcheck | bool | Read/Write | Whether spellchecking is enabled (reflects the spellcheck attribute). | | autocapitalize | str | Read/Write | Auto-capitalisation hint (reflects the autocapitalize attribute). | | nonce | str | Read/Write | Cryptographic nonce for CSP (reflects the nonce attribute). | | autofocus | bool | Read/Write | Whether this element should receive focus on page load. | | access_key_label | str | Read | System-assigned access key label (headless stub: always ''). | | input_mode | str | Read/Write | Virtual keyboard input mode hint (reflects the inputmode attribute). | | enter_key_hint | str | Read/Write | Enter-key action label hint (reflects the enterkeyhint attribute). | | translate | bool | Read/Write | Whether translation is enabled for this element (WHATWG HTML §6.1.2). | | inner_text | str | Read/Write | Rendered text content — whitespace-collapsed text_content. | | outer_text | str | Read/Write | Same as inner_text (getter mirrors inner_text per HTML Standard §3.2.7). | | popover | | Read/Write | Reflects thepopovercontent attribute (WHATWG HTML §6.12). | | `node_name` | `str` | Read | The qualified tag name (uppercase for HTML elements). | | `tag_name` | `str` | Read | The qualified tag name in uppercase (HTML elements). | | `local_name` | `str` | Read | The local part of the qualified name (lowercase). | | `namespace_uri` | `str \| None` | Read | The namespace URI, orNonefor no namespace. | | `style_sheets` | `"StyleSheetList"` | Read | Live stylesheet list applicable to this element's document. | | `prefix` | `str \| None` | Read | The namespace prefix, orNone. | | `id` | `str` | Read | The value of the idattribute, or’’if not present. | | `class_name` | `str` | Read | The value of theclassattribute, or’’. | | `class_list` | `"DOMTokenList"` | Read | Live mutable set of CSS class tokens backed by the classattribute. | | `dataset` | `"DOMStringMap"` | Read | Live dict-like view of the element'sdata-*custom attributes. | | `attributes` | `NamedNodeMap` | Read | The ordered map of Attr objects for this element. | | `children` | `HTMLCollection` | Read | A live HTMLCollection of Element-type children only. | | `first_element_child` | `Element \| None` | Read | The first Element child, orNone. | | `last_element_child` | `Element \| None` | Read | The last Element child, or None. | | `next_element_sibling` | `Element \| None` | Read | The next sibling that is an Element, or None. | | `previous_element_sibling` | `Element \| None` | Read | The previous sibling that is an Element, or None. | | `child_element_count` | `int` | Read | The number of Element children. | | `inner_html` | `str` | Read/Write | The serialised HTML content of all children (innerHTML). | | `outer_html` | `str` | Read/Write | The serialised HTML of this element and all its descendants (outerHTML). | | `text_content` | `str \| None` | Read/Write | The concatenation of all descendant Text node data (DFS order). | | `style` | `"CSSStyleDeclaration"` | Read | The inline style of this element as a live CSSStyleDeclaration. | | `scroll_width` | `int` | Read | Content scroll width in CSS pixels (stub: 0). | | `scroll_height` | `int` | Read | Content scroll height in CSS pixels (stub: 0). | | `client_width` | `int` | Read | Inner width including padding, excluding border (stub: 0). | | `client_height` | `int` | Read | Inner height including padding, excluding border (stub: 0). | | `scroll_top` | `int` | Read/Write | Vertical scroll offset in CSS pixels (stub: 0). | | `scroll_left` | `int` | Read/Write | Horizontal scroll offset in CSS pixels (stub: 0). | | `offset_width` | `int` | Read | Layout border-box width in CSS pixels (stub: 0). | | `offset_height` | `int` | Read | Layout border-box height in CSS pixels (stub: 0). | | `offset_top` | `int` | Read | Top offset from offsetParentin CSS pixels (stub: 0). | | `offset_left` | `int` | Read | Left offset fromoffsetParentin CSS pixels (stub: 0). | | `offset_parent` | `None` | Read | The offset parent element; alwaysNonein headless mode. | | `client_top` | `int` | Read | Width of the top CSS border in pixels; always0in headless mode. | | `client_left` | `int` | Read | Width of the left CSS border in pixels; always0in headless mode. | | `part` | `"DOMTokenList"` | Read | Live DOMTokenList reflecting the elementpartattribute. | | `shadow_root` | | Read | Always None in headless mode. | | slot | str | Read/Write | Reflects the slot content attribute (DOM §4.2.3). | | assigned_slot | | Read | AlwaysNonein headless mode. | | `node_type` | `int` | Read | Integer node type constant fromNodeType. | | `node_value` | `str \| None` | Read/Write | Character data for CharacterData nodes; Noneotherwise. | | `parent_node` | `Node \| None` | Read | The parent node, orNoneif this node has no parent. | | `parent_element` | `Element \| None` | Read | The parent node if it is an Element;Noneotherwise. | | `is_connected` | `bool` | Read | Whether this node is part of a document's node tree (WHATWG DOM §4.4). | | `owner_document` | `Document \| None` | Read | The Document this node belongs to, orNonefor Document itself. | | `child_nodes` | `NodeList` | Read | A live NodeList of all child nodes. | | `first_child` | `Node \| None` | Read | The first child node, orNone. | | `last_child` | `Node \| None` | Read | The last child node, or None. | | `previous_sibling` | `Node \| None` | Read | The preceding sibling node, or None. | | `next_sibling` | `Node \| None` | Read | The following sibling node, or None``. |

Methods

SignatureDescription
click()Dispatch a synthetic click event on this element.
focus(options: "dict | None")Dispatch a non-bubbling 'focus' event on this element.
blur()Dispatch a non-bubbling 'blur' event on this element.
show_popover()Show this element as a popover (no-op in headless mode).
hide_popover()Hide this element’s popover (no-op in headless mode).
toggle_popover(force: "bool | None")boolToggle this element’s popover state (no-op, always returns False).
__init__(local_name: str, namespace_uri: str | None, prefix: str | None, owner_document: Document | None)Calls init(local_name, namespace_uri, prefix, owner_document) on this HTMLHeadElement instance.
get_computed_style()"ComputedStyleDeclaration"Return phase-2 cascade-resolved declarations for this element.
insert_adjacent_html(position: str, html: str)Insert parsed HTML markup relative to this element.
insert_adjacent_text(position: str, text: str)Insert a text node relative to this element.
insert_adjacent_element(position: str, element: "Element | None")"Element | None"Insert element at position relative to this element.
get_attribute(name: str)str | NoneReturn the value of attribute name, or None if absent.
set_attribute(name: str, value: str)Set attribute name to value, creating it if not present.
remove_attribute(name: str)Remove attribute name.
has_attribute(name: str)boolReturn True if attribute name exists on this element.
get_attribute_node(name: str)"Attr | None"Return the Attr object for attribute name, or None if absent.
set_attribute_node(attr: "Attr")"Attr | None"Insert or replace attr in this element’s attribute set.
remove_attribute_node(attr: "Attr")"Attr"Remove attr from this element’s attribute set and return it.
get_attribute_node_ns(namespace_uri: str | None, local_name: str)"Attr | None"Return the Attr node matching namespace_uri and local_name, or None.
set_attribute_node_ns(attr: "Attr")"Attr | None"Insert or replace a namespaced Attr node.
remove_attribute_node_ns(namespace_uri: str | None, local_name: str)"Attr"Remove and return the Attr node matching namespace_uri and local_name.
get_attribute_ns(namespace_uri: str | None, local_name: str)str | NoneReturn the value of the namespaced attribute, or None if absent.
set_attribute_ns(namespace_uri: str | None, qualified_name: str, value: str)Set a namespaced attribute to value, creating it if not present.
has_attribute_ns(namespace_uri: str | None, local_name: str)boolReturn True if a namespaced attribute with the given local name exists.
remove_attribute_ns(namespace_uri: str | None, local_name: str)Remove the namespaced attribute.
toggle_attribute(name: str, force: bool | None)boolToggle attribute name and return its new presence state.
get_attribute_names()list[str]Return the qualified names of all attributes in collection order.
has_attributes()boolReturn True when this element has one or more attributes.
scroll_into_view(arg: bool | dict | None)Scroll this element into view (no-op in server-side context).
scroll(x_or_options: float | dict | None, y: float | None)Scroll this element to coordinates (no-op in server-side context).
scroll_into_view_if_needed(center_if_needed: bool)Scroll this element into view if it is not already visible (no-op in headless mode).
set_pointer_capture(pointer_id: int)Designate this element as the capture target for the given pointer (no-op).
release_pointer_capture(pointer_id: int)Release pointer capture for the given pointer id (no-op).
has_pointer_capture(pointer_id: int)boolReturn whether this element has pointer capture for the given id.
request_pointer_lock()Request that the pointer be locked to this element (no-op).
request_fullscreen(options: "dict | None")Request that this element be displayed in fullscreen mode (no-op).
check_visibility(options: "dict | None")boolReturn whether this element is visible in the current rendering (always True).
query_selector(selector: str)Element | NoneReturn the first element in the subtree matching selector.
query_selector_all(selector: str)NodeListReturn a static NodeList of all elements matching selector.
matches(selector: str)boolReturn True if this element matches the CSS selector.
webkit_matches_selector(selector: str)boolBrowser-compat alias for :meth:matches.
closest(selector: str)"Element | None"Return the nearest ancestor (inclusive) matching the CSS selector.
get_elements_by_tag_name(qualified_name: str)HTMLCollectionReturn all descendant elements whose tag name matches qualified_name.
get_elements_by_class_name(class_names: str)HTMLCollectionReturn all descendant elements that carry all of the given class tokens.
filter_fn(el: "Element")boolCalls filter_fn(el) on this HTMLHeadElement instance.
remove()Remove this element from its parent node.
before()Insert nodes immediately before this element in its parent.
after()Insert nodes immediately after this element in its parent.
replace_with()Replace this element with nodes in its parent.
prepend()Insert nodes before the first child of this element.
append()Append nodes as the last children of this element.
replace_children()Remove all children, then append nodes as new children.
get_bounding_client_rect()"DOMRect"Return the bounding client rectangle (all-zero stub).
get_client_rects()"DOMRectList"Return the client rectangle list (empty in server-side context).
get_animations()list[object]Return active animations for this element (headless stub: always []).
attach_shadow(init: "dict | None")Raise NotSupportedError — shadow trees are not supported in headless mode.
get_root_node(composed: bool)"Node"Return the root of the node’s tree.
has_child_nodes()boolReturn whether this node has at least one direct child node.
lookup_namespace_uri(prefix: str | None)str | NoneReturn the effective namespace URI for prefix in this node context.
lookup_prefix(namespace_uri: str | None)str | NoneReturn the effective prefix for namespace_uri in this node context.
is_default_namespace(namespace_uri: str | None)boolReturn whether namespace_uri equals this node context default namespace.
is_supported(feature: str, version: str | None)boolReturn legacy feature-probe compatibility status.
get_feature(feature: str, version: str | None)object | NoneReturn the legacy feature object for a probe, or None.
set_user_data(key: str, data: object | None, handler: object | None)object | NoneStore or clear node-local user data and return the previous value.
get_user_data(key: str)object | NoneReturn node-local user data for key or None when absent.
append_child(node: Node)NodeAppend node as the last child of this node.
insert_before(node: Node, reference: Node | None)NodeInsert node before reference in the child list.
remove_child(node: Node)NodeRemove node from the child list and return it.
replace_child(new_child: Node, old_child: Node)NodeReplace old_child with new_child.
clone_node(deep: bool)NodeReturn a copy of this node.
normalize()Put this node and its entire subtree into normalized form.
contains(other: Node | None)boolReturn True if other is an inclusive descendant of this node.
compare_document_position(other: "Node")intReturn a bitmask describing the position of other relative to this node.
is_equal_node(other: Node | None)boolReturn True if other has the same structure as this node.
is_same_node(other_node: Node | None)boolReturn True when other_node is this node instance.
add_event_listener(type: str, listener: Callable, capture: bool, once: bool)Register listener for events of type.
remove_event_listener(type: str, listener: Callable, capture: bool)Deregister a previously-registered listener.
dispatch_event(event: "Event")boolDispatch event through the ancestor tree.

See Also