picture

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package picture provides constructors and methods for the HTML <picture> element.

The <picture> HTML element provides a container for multiple image sources, enabling art direction and responsive images. Contains zero or more <source> elements followed by one <img> element. Allows serving different images based on viewport size, resolution, or format support. Essential for responsive design, serving modern image formats with fallbacks, and optimising bandwidth across devices.

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<picture")
	TagClose = []byte("</picture>")
)

Byte constants for HTML rendering.

Functions

func New

func New(nodes ...node.Node) *element

New creates a new picture element with source and img child elements. Example: picture.New(source.ImageWebP("photo.webp"), img.Src("photo.jpg")) Renders: <picture><source srcset="photo.webp" type="image/webp"><img src="photo.jpg"></picture>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL