Skip to content

dart:html ​

HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model).

INFO

This core library is deprecated, and scheduled for removal in late 2025. It has been replaced by package:web. The migration guide has more details.

This library includes DOM element types, CSS styling, local storage, media, speech, events, and more. To get started, check out the Element class, the base class for many of the HTML DOM types.

For information on writing web apps with Dart, see https://dart.dev/web.

Classes ​

ClassDescription
AbortPaymentEvent
AbsoluteOrientationSensor
AbstractWorker
Accelerometer
AccessibleNode
AccessibleNodeList
AmbientLightSensor
AnchorElement
Animation
AnimationEffectReadOnly
AnimationEffectTiming
AnimationEffectTimingReadOnly
AnimationEvent
AnimationPlaybackEvent
AnimationTimeline
AnimationWorkletGlobalScope
ApplicationCacheApplicationCache is accessed via Window.applicationCache.
ApplicationCacheErrorEvent
AreaElementDOM Area Element, which links regions of an image map with a hyperlink.
AudioElement
AuthenticatorAssertionResponse
AuthenticatorAttestationResponse
AuthenticatorResponse
BackgroundFetchClickEvent
BackgroundFetchedEvent
BackgroundFetchEvent
BackgroundFetchFailEvent
BackgroundFetchFetch
BackgroundFetchManager
BackgroundFetchRegistration
BackgroundFetchSettledFetch
BarcodeDetector
BarProp
BaseElement
BatteryManager
BeforeInstallPromptEvent
BeforeUnloadEvent
Blob
BlobEvent
BluetoothRemoteGattDescriptor
Body
BodyElement
BRElement
BroadcastChannel
BudgetState
ButtonElement
ButtonInputElementA button, with no default behavior.
CacheStorage
CanMakePaymentEvent
CanvasCaptureMediaStreamTrack
CanvasElement
CanvasGradientAn opaque canvas object representing a gradient.
CanvasImageSourceAn object that can be drawn to a 2D canvas rendering context.
CanvasPatternAn opaque object representing a pattern of image, canvas, or video.
CanvasRenderingContext
CanvasRenderingContext2D
CDataSection
CharacterData
CheckboxInputElementA boolean editor control.
ChildNode
Client
Clients
ClipboardEvent
CloseEvent
Comment
CompositionEvent
Console
ContentElement
CookieStore
Coordinates
Credential
CredentialsContainer
CredentialUserData
Crypto
CryptoKey
Css
CssCharsetRule
CssClassSetA Set that stores the CSS class names for an element.
CssConditionRule
CssFontFaceRule
CssGroupingRule
CssImageValue
CssImportRule
CssKeyframeRule
CssKeyframesRule
CssKeywordValue
CssMatrixComponent
CssMediaRule
CssNamespaceRule
CssNumericValue
CssPageRule
CssPerspective
CssPositionValue
CssRectA class for representing CSS dimensions.
CssResourceValue
CssRotation
CssRule
CssScale
CssSkew
CssStyleDeclaration
CssStyleDeclarationBase
CssStyleRule
CssStyleSheet
CssStyleValue
CssSupportsRule
CssTransformComponent
CssTransformValue
CssTranslation
CssUnitValue
CssUnparsedValue
CssurlImageValue
CssVariableReferenceValue
CssViewportRule
CustomElementRegistry
CustomEvent
CustomStream<T extends Event>A stream of custom events, which enables the user to "fire" (add) their own custom events to a stream.
DataElement
DataListElement
DataTransfer
DataTransferItem
DataTransferItemList
DateInputElementA date (year, month, day) with no time zone.
DedicatedWorkerGlobalScope
DeprecatedStorageInfo
DeprecatedStorageQuota
DeprecationReport
DetailsElement
DetectedBarcode
DetectedFace
DetectedText
DeviceAcceleration
DeviceMotionEvent
DeviceOrientationEvent
DeviceRotationRate
DialogElement
DimensionClass representing a length measurement in CSS.
DirectoryEntry
DirectoryReader
DivElementA generic container for content on an HTML page; corresponds to the <div> tag.
DListElement
DocumentThe base class for all documents.
DocumentFragment
DocumentOrShadowRoot
DocumentTimeline
DomError
DomException
DomImplementation
DomIterator
DomMatrix
DomMatrixReadOnly
DomParser
DomPoint
DomPointReadOnly
DomQuad
DomRectList
DomRectReadOnly
DomStringList
DomStringMap
DomTokenList
ElementAn abstract class, which all HTML elements extend.
ElementEvents
ElementList<T extends Element>An immutable list containing HTML elements. This list contains some additional methods when compared to regular lists for ease of CSS manipulation on a group of elements.
ElementStream<T extends Event>A specialized Stream available to Elements to enable event delegation.
ElementUpgraderA utility for changing the Dart wrapper type for elements.
EmailInputElementAn e-mail address or list of e-mail addresses.
EmbedElement
Entry
ErrorEvent
Event
EventsBase class that supports listening for and dispatching browser events.
EventSource
EventStreamProvider<T extends Event>A factory to expose DOM events as Streams.
EventTargetBase class for all browser objects that support events.
ExtendableEvent
ExtendableMessageEvent
External
FaceDetector
FederatedCredential
FetchEvent
FieldSetElement
File
FileEntry
FileList
FileReader
FileSystem
FileUploadInputElementA control for picking files from the user's computer.
FileWriter
FixedSizeListIterator<T>
FocusEvent
FontFace
FontFaceSet
FontFaceSetLoadEvent
FontFaceSource
ForeignFetchEvent
FormData
FormElement
Gamepad
GamepadButton
GamepadEvent
GamepadPose
Geolocation
Geoposition
GlobalEventHandlers
Gyroscope
HashChangeEvent
HeadElement
Headers
HeadingElement
HiddenInputElementHidden input which is not intended to be seen or edited by the user.
History
HistoryBase
HRElementAn <hr> tag.
HtmlCollection
HtmlDocument
HtmlElement
HtmlFormControlsCollection
HtmlHtmlElement
HtmlHyperlinkElementUtils
HtmlOptionsCollection
HttpRequestA client-side XHR request for getting data from a URL, formally known as XMLHttpRequest.
HttpRequestEventTarget
HttpRequestUpload
HttpStatusHTTP status codes. Exported in dart:io and dart:html.
IdleDeadline
IFrameElement
ImageBitmap
ImageBitmapRenderingContext
ImageButtonInputElementEither an image which the user can select a coordinate to or a form submit button.
ImageCapture
ImageData
ImageElement
ImmutableListMixin<E>
InputDeviceCapabilities
InputElement
InputElementBaseExposes the functionality common between all InputElement types.
InstallEvent
IntersectionObserver
IntersectionObserverEntry
InterventionReport
KeyboardEventAn event that describes user interaction with the keyboard.
KeyboardEventStreamRecords KeyboardEvents that occur on a particular element, and provides a stream of outgoing KeyEvents with cross-browser consistent keyCode and charCode values despite the fact that a multitude of browsers that have varying keyboard default behavior.
KeyCodeDefines the keycode values for keys that are returned by KeyboardEvent.keyCode.
KeyEventA custom KeyboardEvent that attempts to eliminate cross-browser inconsistencies, and also provide both keyCode and charCode information for all key events (when such information can be determined).
KeyframeEffect
KeyframeEffectReadOnly
KeyLocationDefines the standard key locations returned by KeyboardEvent.getKeyLocation.
LabelElement
LegendElement
LIElement
LinearAccelerationSensor
LinkElement
LocalDateTimeInputElementA date and time (year, month, day, hour, minute, second, fraction of a second) with no time zone.
Location
LocationBase
Magnetometer
MapElement
MathMLElement
MediaCapabilities
MediaCapabilitiesInfo
MediaDeviceInfo
MediaDevices
MediaElement
MediaEncryptedEvent
MediaError
MediaKeyMessageEvent
MediaKeys
MediaKeySession
MediaKeysPolicy
MediaKeyStatusMap
MediaKeySystemAccess
MediaList
MediaMetadata
MediaQueryList
MediaQueryListEvent
MediaRecorder
MediaSession
MediaSettingsRange
MediaSource
MediaStream
MediaStreamEvent
MediaStreamTrack
MediaStreamTrackEvent
MemoryInfo
MenuElementAn HTML <menu> element.
MessageChannel
MessageEvent
MessagePort
Metadata
MetaElement
MeterElement
MidiAccess
MidiConnectionEvent
MidiInput
MidiInputMap
MidiMessageEvent
MidiOutput
MidiOutputMap
MidiPort
MimeType
MimeTypeArray
ModElement
MonthInputElementA date consisting of a year and a month with no time zone.
MouseEvent
MutationEvent
MutationObserver
MutationRecord
NavigationPreloadManager
Navigator
NavigatorAutomationInformation
NavigatorConcurrentHardware
NavigatorCookies
NavigatorID
NavigatorLanguage
NavigatorOnLine
NavigatorUserMediaError
NetworkInformation
Node
NodeFilter
NodeIterator
NodeList
NodeTreeSanitizerPerforms sanitization of a node tree after construction to ensure that it does not contain any disallowed elements or attributes.
NodeValidatorInterface used to validate that only accepted elements and attributes are allowed while parsing HTML strings into DOM nodes.
NodeValidatorBuilderClass which helps construct standard node validation policies.
NoncedElement
NonDocumentTypeChildNode
NonElementParentNode
Notification
NotificationEvent
NumberInputElementA numeric editor control.
ObjectElement
OffscreenCanvas
OffscreenCanvasRenderingContext2D
OListElement
OptGroupElement
OptionElement
OrientationSensor
OutputElement
OverconstrainedError
PageTransitionEvent
PaintRenderingContext2D
PaintSize
PaintWorkletGlobalScope
ParagraphElement
ParamElement
ParentNode
PasswordCredential
PasswordInputElementText with no line breaks (sensitive information).
Path2D
PaymentAddress
PaymentInstruments
PaymentManager
PaymentRequest
PaymentRequestEvent
PaymentRequestUpdateEvent
PaymentResponse
Performance
PerformanceEntry
PerformanceLongTaskTiming
PerformanceMark
PerformanceMeasure
PerformanceNavigation
PerformanceNavigationTiming
PerformanceObserver
PerformanceObserverEntryList
PerformancePaintTiming
PerformanceResourceTiming
PerformanceServerTiming
PerformanceTiming
Permissions
PermissionStatus
PhotoCapabilities
PictureElement
Platform
Plugin
PluginArray
Point<T extends num>A utility class for representing two-dimensional positions.
PointerEvent
PopStateEvent
PositionError
PreElement
Presentation
PresentationAvailability
PresentationConnection
PresentationConnectionAvailableEvent
PresentationConnectionCloseEvent
PresentationConnectionList
PresentationReceiver
PresentationRequest
ProcessingInstruction
ProgressElement
ProgressEvent
PromiseRejectionEvent
PublicKeyCredential
PushEvent
PushManager
PushMessageData
PushSubscription
PushSubscriptionOptions
QuoteElement
RadioButtonInputElementA control that when used with other RadioButtonInputElement controls forms a radio button group in which only one control can be checked at a time.
Range
RangeInputElementSimilar to NumberInputElement but the browser may provide more optimal styling (such as a slider control).
RangeInputElementBaseBase interface for all input element types which involve ranges.
ReadyStateContains the set of standard values returned by HTMLDocument.getReadyState.
Rectangle<T extends num>A class for representing two-dimensional rectangles whose properties are immutable.
RelatedApplication
RelativeOrientationSensor
RemotePlayback
ReportBody
ReportingObserver
ResetButtonInputElementA button, which when clicked, resets the form.
ResizeObserver
ResizeObserverEntry
RtcCertificate
RtcDataChannel
RtcDataChannelEvent
RtcDtmfSender
RtcDtmfToneChangeEvent
RtcIceCandidate
RtcLegacyStatsReport
RtcPeerConnection
RtcPeerConnectionIceEvent
RtcRtpContributingSource
RtcRtpReceiver
RtcRtpSender
RtcSessionDescription
RtcStatsReport
RtcStatsResponse
RtcTrackEvent
Screen
ScreenOrientation
ScriptElement
ScrollAlignmentOptions for Element.scrollIntoView.
ScrollState
ScrollTimeline
SearchInputElementSimilar to TextInputElement, but on platforms where search is styled differently this will get the search style.
SecurityPolicyViolationEvent
SelectElement
Selection
Sensor
SensorErrorEvent
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
ShadowElement
ShadowRoot
SharedArrayBuffer
SharedWorker
SharedWorkerGlobalScope
SlotElement
SourceBuffer
SourceBufferList
SourceElement
SpanElement
SpeechGrammar
SpeechGrammarList
SpeechRecognition
SpeechRecognitionAlternative
SpeechRecognitionError
SpeechRecognitionEvent
SpeechRecognitionResult
SpeechSynthesis
SpeechSynthesisEvent
SpeechSynthesisUtterance
SpeechSynthesisVoice
StaticRange
StorageThe type used by the Window.localStorage and Window.sessionStorage properties. Storage is implemented as a Map<String, String>.
StorageEvent
StorageManager
StyleElement
StyleMedia
StylePropertyMap
StylePropertyMapReadonly
StyleSheet
SubmitButtonInputElementA button, which when clicked, submits the form.
SyncEvent
SyncManager
TableCaptionElement
TableCellElement
TableColElement
TableElement
TableRowElement
TableSectionElement
TaskAttributionTiming
TelephoneInputElementRepresents a control for editing a telephone number.
TemplateElement
Text
TextAreaElement
TextDetector
TextEvent
TextInputElementA basic text input editor control.
TextInputElementBaseBase interface for all inputs which involve text editing.
TextMetrics
TextTrack
TextTrackCue
TextTrackCueList
TextTrackList
TimeElement
TimeInputElementA time (hour, minute, seconds, fractional seconds) with no time zone.
TimeRanges
TitleElement
Touch
TouchEvent
TouchList
TrackDefault
TrackDefaultList
TrackElement
TrackEvent
TransitionEvent
TreeWalker
TrustedHtml
TrustedScriptUrl
TrustedUrl
UIEvent
UListElement
UnderlyingSourceBase
UnknownElement
UriPolicyDefines the policy for what types of uris are allowed for particular attribute values.
Url
UrlInputElementA control for editing an absolute URL.
UrlSearchParams
UrlUtilsReadOnly
ValidityState
VideoElement
VideoPlaybackQuality
VideoTrack
VideoTrackList
VisualViewport
VR
VRCoordinateSystem
VRDevice
VRDeviceEvent
VRDisplay
VRDisplayCapabilities
VRDisplayEvent
VREyeParameters
VRFrameData
VRFrameOfReference
VRPose
VRSession
VRSessionEvent
VRStageBounds
VRStageBoundsPoint
VRStageParameters
VttCue
VttRegion
WebSocketUse the WebSocket interface to connect to a WebSocket, and to send and receive data on that WebSocket.
WeekInputElementA date consisting of a week-year number and a week number with no time zone.
WheelEvent
WindowTop-level container for the current browser tab or window.
WindowBaseTop-level container for a browser tab or window.
WindowBase64
WindowClient
WindowEventHandlers
Worker
WorkerGlobalScope
WorkerPerformance
WorkletAnimation
WorkletGlobalScope
XmlDocument
XmlSerializer
XPathEvaluator
XPathExpression
XPathNSResolver
XPathResult
XsltProcessor

Exceptions ​

ExceptionDescription
NullWindowException

Functions ​

FunctionDescription
promiseToFuture<T>Converts a JavaScript Promise to a Dart Future.
promiseToFutureAsMapConvert a JS Promise to a Future<Map<String, dynamic>>.
querySelectorFinds the first descendant element of this document that matches the specified group of selectors.
querySelectorAll<T extends Element>Finds all descendant elements of this document that match the specified group of selectors.

Properties ​

PropertyDescription
documentRoot node for all content in a web page.
windowTop-level container for a web page, which is usually a browser tab or window.

Typedefs ​

TypedefDescription
BlobCallback
CustomElementConstructor
DecodeErrorCallback
DecodeSuccessCallback
EventListener
FontFaceSetForEachCallbackEmitted for any setlike IDL entry needs a callback signature. Today there is only one.
FrameRequestCallback
FunctionStringCallback
IdleRequestCallback
IntersectionObserverCallback
MediaSessionActionHandler
MessageCallback
MetadataCallback
MojoWatchCallback
MutationCallback
PerformanceObserverCallback
RemotePlaybackAvailabilityCallback
ReportingObserverCallback
RequestAnimationFrameCallback
ResizeObserverCallback
RtcPeerConnectionErrorCallback
RtcStatsCallback
ScrollStateCallback
StorageErrorCallback
StorageQuotaCallback
StorageUsageCallback
TimeoutHandler
VoidCallback