Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<style") TagClose = []byte("</style>") AttrType = []byte(" type=\"") AttrMedia = []byte(" media=\"") AttrNonce = []byte(" nonce=\"") AttrTitle = []byte(" title=\"") AttrBlocking = []byte(" blocking=\"") )
Byte constants for HTML rendering.
Functions ¶
func CSS ¶
func CSS(css string) *element
CSS Creates a style element with CSS type explicitly set. Example: style.CSS("body { margin: 0; padding: 0; }") Renders: <style type="text/css">body { margin: 0; padding: 0; }</style>
func New ¶
New Creates a new style element without any initial attributes. Example: style.New() Renders: <style></style>
func RawText ¶
func RawText(content string) *element
RawText Creates a new style element with raw CSS content. Uses text.RawText which is not HTML-escaped. Preferred for dynamic inline stylesheets. Example: style.RawText("body { margin: 0; }") Renders: <style>body { margin: 0; }</style>
func RawTextf ¶
RawTextf Creates a new style element with formatted raw CSS content. Uses text.RawTextf which is not HTML-escaped. Preferred for dynamic inline stylesheets with interpolation. Example: style.RawTextf(".%s { color: %s; }", className, colour) Renders: <style>.highlight { color: red; }</style>
func Static ¶
func Static(content string) *element
Static Creates a new style element with static CSS content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Preferred for compile-time constant stylesheets. Example: style.Static("body { margin: 0; }") Renders: <style>body { margin: 0; }</style>
func Text ¶
func Text(content string) *element
Text Creates a new style element with text content. Uses text.Text which HTML-escapes the output. Warning: HTML escaping will break CSS syntax (e.g., > in selectors). Use RawText, Static, or CSS instead. Example: style.Text("body { margin: 0; }") Renders: <style>body { margin: 0; }</style>