Documentation
¶
Overview ¶
Package html provides constructors and methods for the HTML <html> element.
The <html> HTML element represents the root (top-level element) of an HTML document, so it is also referred to as the root element. All other elements must be descendants of this element. There can be only one <html> element in a document.
Index ¶
- Variables
- func Fragment(nodes ...node.Node) *element
- func FragmentRawText(str string) *element
- func FragmentRawTextf(format string, args ...any) *element
- func FragmentStatic(str string) *element
- func FragmentText(str string) *element
- func FragmentTextf(format string, args ...any) *element
- func New(nodes ...node.Node) *element
- func RawText(str string) *element
- func RawTextf(format string, args ...any) *element
- func Static(str string) *element
- func Text(str string) *element
- func Textf(format string, args ...any) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<html") TagClose = []byte("</html>") AttrLang = []byte(" lang=\"") AttrXmlns = []byte(" xmlns=\"") AttrManifest = []byte(" manifest=\"") )
Byte constants for HTML rendering.
Functions ¶
func Fragment ¶
Fragment creates an html fragment without DOCTYPE declaration (for fragments or embedded use) Example: html.Fragment() Renders: <html></html>
func FragmentRawText ¶
func FragmentRawText(str string) *element
FragmentRawText creates an html fragment without DOCTYPE declaration with raw text content. Uses text.RawText which is not HTML-escaped. Example: html.FragmentRawText("<body>Content</body>") Renders: <html><body>Content</body></html>
func FragmentRawTextf ¶
FragmentRawTextf creates an html fragment without DOCTYPE declaration with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: html.FragmentRawTextf("<body><h1>%s</h1></body>", title) Renders: <html><body><h1>Dashboard</h1></body></html>
func FragmentStatic ¶
func FragmentStatic(str string) *element
FragmentStatic creates an html fragment without DOCTYPE declaration with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: html.FragmentStatic("Fragment content") Renders: <html>Fragment content</html>
func FragmentText ¶
func FragmentText(str string) *element
FragmentText creates an html fragment without DOCTYPE declaration with text content. Uses text.Text which HTML-escapes the output. Example: html.FragmentText("Content") Renders: <html>Content</html>
func FragmentTextf ¶
FragmentTextf creates an html fragment without DOCTYPE declaration with formatted text content. Uses text.Textf which HTML-escapes the output. Example: html.FragmentTextf("Page for %s", name) Renders: <html>Page for Mary</html>
func New ¶
New creates a complete HTML5 document with DOCTYPE declaration Example: html.New() Renders: <!DOCTYPE html><html></html>
func RawText ¶
func RawText(str string) *element
RawText creates a complete HTML5 document with DOCTYPE declaration and raw text content. Uses text.RawText which is not HTML-escaped. Example: html.RawText("<body>Content</body>") Renders: <!DOCTYPE html><html><body>Content</body></html>
func RawTextf ¶
RawTextf creates a complete HTML5 document with DOCTYPE declaration and formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: html.RawTextf("<body><h1>%s</h1></body>", title) Renders: <!DOCTYPE html><html><body><h1>Dashboard</h1></body></html>
func Static ¶
func Static(str string) *element
Static creates a complete HTML5 document with DOCTYPE declaration and static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: html.Static("Minimal page") Renders: <!DOCTYPE html><html>Minimal page</html>