Class Meta<T extends Meta<T>>
- All Implemented Interfaces:
HeadElement
<meta> element that defines metadata about an HTML document.
The <meta> element provides information about the HTML document such as character encoding,
page description, keywords, author, viewport settings, and other metadata. Meta tags are placed in
the document's head section and are not displayed on the page.
Features:
- Character encoding specification (UTF-8, ISO-8859-1, etc.)
- HTTP header equivalents (refresh, content-type, etc.)
- Standard metadata (description, keywords, author, viewport)
- OpenGraph and social media metadata support
- Self-closing tag (no closing tag required)
- ID attribute excluded by default
Usage:
// Character encoding
Meta charset = new Meta();
charset.setCharset("UTF-8");
// Page description
Meta description = new Meta("name", "description", "Page description text");
// Viewport settings
Meta viewport = new Meta("name", "viewport");
viewport.setContent("width=device-width, initial-scale=1.0");
// HTTP refresh
Meta refresh = new Meta();
refresh.setHttpEquiv("refresh");
refresh.setContent("30");
// OpenGraph property
Meta ogTitle = new Meta();
ogTitle.setProperty("og:title");
ogTitle.setContent("Page Title");
- Since:
- 2007
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsetCharset(String characterSet) Sets the character encoding for the document.final TsetContent(String text) Sets the content value for this meta element.final TsetHttpEquiv(HttpEquiv httpEquiv) Sets the HTTP-equiv pragma directive using theHttpEquivenum.final TsetHttpEquiv(String httpEquiv) Sets the HTTP-equiv pragma directive using a string value.final TSets the media attribute specifying the media query for which this metadata applies.final TSets the name attribute identifying the metadata type.final TsetProperty(String property) Sets the property attribute for extended metadata protocols.Methods inherited from class com.oorian.html.Element
addAttribute, addAttribute, addAttribute, addAttribute, addElement, addLineBreak, addLineOfText, addLineOfText, addLineOfText, addParagraph, addParagraph, addSpacer, addText, addText, addText, addText, assignId, containsElement, containsElement, create, dispatchEvent, dispatchEvent, dispatchEvent, dispatchEvent, equals, excludeId, executeJs, executeJs, executeJs, getAccept, getAllElements, getAncestor, getAttribute, getAttributes, getComponent, getDir, getElement, getElementById, getElementCount, getElementCount, getElements, getElements, getElementsByComponentName, getElementsByTagName, getHtml, getHtml, getId, getInnerHtml, getInnerHtml, getIs, getItemId, getItemProp, getItemRef, getItemType, getLang, getNextSibling, getPage, getParent, getPart, getPrevSibling, getSlot, getTagName, getTextContent, getUrl, hasAttribute, hasElements, hidden, initialize, insertElement, isChildOf, isClosedTag, isCreated, isDescendantOf, isDescendantOf, isInitialized, isItemScope, isTranslate, onCallback, onCreated, onElementAdded, onElementRemoved, onHashChange, onHidden, onInitialized, onJsReturn, onPageLoaded, onPageUnloaded, onRefresh, onRemovedFromPage, onShown, onUpdated, onUserEvent, prewrite, recreate, refresh, refresh, registerAddition, registerListener, registerListener, registerListener, registerListener, registerListener, registerListener, registerListener, registerSubtraction, registerUpdate, removeAllElements, removeAttribute, removeAttribute, removeElement, removeElement, removeFromParent, requestCallback, requestCallback, requestCallback, requestCallback, resetId, scrollTo, scrollToBottom, scrollToTop, self, sendCommand, sendUpdate, setAccept, setComponent, setDir, setDir, setElement, setId, setIs, setItemId, setItemProp, setItemRef, setItemScope, setItemType, setLang, setOnError, setOnLoad, setPage, setParent, setPart, setSlot, setTagName, setText, setText, setText, setText, setTranslate, shown, toString, unregisterListener, update, updateAttributes
-
Constructor Details
-
Meta
public Meta()Constructs a new Meta element.Creates a self-closing
<meta>tag with ID attribute excluded. -
Meta
Constructs a new Meta element with a specified attribute and value.This constructor is useful for creating meta tags with a single attribute-value pair, such as
<meta name="viewport">.- Parameters:
attribute- the attribute name (e.g., "name", "property", "http-equiv")value- the attribute value (e.g., "viewport", "og:title", "refresh")
-
Meta
Constructs a new Meta element with an attribute, value, and content.This constructor provides a convenient way to create complete meta tags with both an identifying attribute and content in a single statement.
- Parameters:
attribute- the attribute name (e.g., "name", "property", "http-equiv")value- the attribute value (e.g., "description", "og:description")content- the content value for the meta tag
-
-
Method Details
-
setCharset
Sets the character encoding for the document.Specifies the character encoding used by the document. The most common value is
"UTF-8". This attribute is mutually exclusive with thehttp-equivattribute.- Parameters:
characterSet- the character encoding (e.g., "UTF-8")- Returns:
- this element for method chaining
-
setContent
Sets the content value for this meta element.The content attribute provides the value associated with the
name,http-equiv, orpropertyattribute.- Parameters:
text- the content value- Returns:
- this element for method chaining
-
setHttpEquiv
Sets the HTTP-equiv pragma directive using a string value.Defines a pragma directive that simulates an HTTP response header. Common values include
"content-type","refresh","default-style", and"content-security-policy".- Parameters:
httpEquiv- the pragma directive name- Returns:
- this element for method chaining
-
setHttpEquiv
Sets the HTTP-equiv pragma directive using theHttpEquivenum.- Parameters:
httpEquiv- The pragma directive.- Returns:
- This element for method chaining.
-
setName
Sets the name attribute identifying the metadata type.Common values include
"description","keywords","author","viewport", and"robots".- Parameters:
name- The metadata name.- Returns:
- This element for method chaining.
-
setMedia
Sets the media attribute specifying the media query for which this metadata applies.- Parameters:
media- The media query string.- Returns:
- This element for method chaining.
-
setProperty
Sets the property attribute for extended metadata protocols.The property attribute is used for metadata protocols like OpenGraph (og:*) and Twitter Cards (twitter:*). This allows rich social media integration.
- Parameters:
property- the property name (e.g., "og:title", "og:description", "twitter:card")- Returns:
- this element for method chaining
-