class Elements

This class provides general information about HTML5 elements, including syntactic and semantic issues.

Parsers and serializers can use this class as a reference point for information about the rules of various HTML5 elements.

Constants

KNOWN_ELEMENT

Indicates an element is described in the specification.

TEXT_RAW

Indicates the contained text should be processed as raw text.

TEXT_RCDATA

Indicates the contained text should be processed as RCDATA.

VOID_TAG

Indicates the tag cannot have content.

AUTOCLOSE_P

Indicates that if a previous event is for a P tag, that element should be considered closed.

TEXT_PLAINTEXT

Indicates that the text inside is plaintext (pre).

BLOCK_TAG

Indicates that the tag is a block.

BLOCK_ONLY_INLINE

Indicates that the tag allows only inline elements as child nodes.

Properties

static array $html5 The HTML5 elements as defined in http://dev.w3.org/html5/markup/elements.html.
static array $mathml The MathML elements.
static array $svg The svg elements.
static $svgCaseSensitiveAttributeMap Some attributes in SVG are case sensetitive.
static $svgCaseSensitiveElementMap Some SVG elements are case sensetitive.

Methods

static  boolean
isA( string $name, int $mask)

Check whether the given element meets the given criterion.

static  bool
isHtml5Element( string $name)

Test if an element is a valid html5 element.

static  bool
isMathMLElement( string $name)

Test if an element name is a valid MathML presentation element.

static  boolean
isSvgElement( string $name)

Test if an element is a valid SVG element.

static  bool
isElement( string $name)

Is an element name valid in an html5 document.

static  int
element( string $name)

Get the element mask for the given element name.

static  string
normalizeSvgElement( string $name)

Normalize a SVG element name to its proper case and form.

static  string
normalizeSvgAttribute( string $name)

Normalize a SVG attribute name to its proper case and form.

static  string
normalizeMathMlAttribute( string $name)

Normalize a MathML attribute name to its proper case and form.

Details

at line line 486
static boolean isA( string $name, int $mask)

Check whether the given element meets the given criterion.

Example:

Elements::isA('script', Elements::TEXT_RAW); // Returns true.

Elements::isA('script', Elements::TEXT_RCDATA); // Returns false.

Parameters

string $name The element name.
int $mask One of the constants on this class.

Return Value

boolean true if the element matches the mask, false otherwise.

at line line 503
static bool isHtml5Element( string $name)

Test if an element is a valid html5 element.

Parameters

string $name The name of the element.

Return Value

bool True if a html5 element and false otherwise.

at line line 518
static bool isMathMLElement( string $name)

Test if an element name is a valid MathML presentation element.

Parameters

string $name The name of the element.

Return Value

bool True if a MathML name and false otherwise.

at line line 532
static boolean isSvgElement( string $name)

Test if an element is a valid SVG element.

Parameters

string $name The name of the element.

Return Value

boolean True if a SVG element and false otherise.

at line line 549
static bool isElement( string $name)

Is an element name valid in an html5 document.

This includes html5 elements along with other allowed embedded content such as svg and mathml.

Parameters

string $name The name of the element.

Return Value

bool True if valid and false otherwise.

at line line 562
static int element( string $name)

Get the element mask for the given element name.

Parameters

string $name The name of the element.

Return Value

int The element mask.

at line line 585
static string normalizeSvgElement( string $name)

Normalize a SVG element name to its proper case and form.

Parameters

string $name The name of the element.

Return Value

string The normalized form of the element name.

at line line 603
static string normalizeSvgAttribute( string $name)

Normalize a SVG attribute name to its proper case and form.

Parameters

string $name The name of the attribute.

Return Value

string The normalized form of the attribute name.

at line line 623
static string normalizeMathMlAttribute( string $name)

Normalize a MathML attribute name to its proper case and form.

Note, all MathML element names are lowercase.

Parameters

string $name The name of the attribute.

Return Value

string The normalized form of the attribute name.