Attributo di stile HTML
Esempio
Utilizzo dell'attributo style in un documento HTML:
<h1 style="color:blue;text-align:center;">This is a header</h1>
<p style="color:green;">This is a paragraph.</p>
Definizione e utilizzo
L' style
attributo specifica uno stile inline per un elemento.
L' style
attributo sovrascriverà qualsiasi stile impostato a livello globale, ad esempio gli stili specificati nel <style>
tag o in un foglio di stile esterno.
L' style
attributo può essere utilizzato su qualsiasi elemento HTML (verrà convalidato su qualsiasi elemento HTML. Tuttavia, non è necessariamente utile).
Supporto browser
Attribute | |||||
---|---|---|---|---|---|
style | Yes | Yes | Yes | Yes | Yes |
Sintassi
<element style="style_definitions">
Valori di attributo
Value | Description |
---|---|
style_definitions | One or more CSS properties and values separated by semicolons (e.g. style="color:blue;text-align:center") |
Pagine correlate
Esercitazione HTML: attributi HTML
Esercitazione CSS: Introduzione ai CSS
Tutorial JavaScript: JavaScript HTML DOM - Modifica CSS
Riferimento HTML DOM: Oggetto stile HTML DOM
Riferimento HTML DOM: Proprietà in stile HTML DOM
Riferimento HTML DOM: metodo JS getComputedStyle()