Skip to main content

is_void_element

Function is_void_element 

Source
pub fn is_void_element(name: &str) -> bool
Expand description

Returns true if the element is a void element (no closing tag).

Void elements are HTML elements that cannot have content and must not have a closing tag. Per the HTML5 specification, these are:

  • area, base, br, col, embed, hr, img, input
  • link, meta, param, source, track, wbr

ยงExamples

use scrape_core::utils::is_void_element;

assert!(is_void_element("br"));
assert!(is_void_element("img"));
assert!(is_void_element("input"));

assert!(!is_void_element("div"));
assert!(!is_void_element("span"));
assert!(!is_void_element("p"));