L'element HTML <hr>
representa un trencament temàtic entre els elements a nivell de paràgraf (per exemple, un canvi d'escena en una història, o un canvi de tema amb una secció). En versions prèvies d'HTML, es representava amb una regla horitzontal. Encara es pot mostrar com una regla horitzontal en els navegadors visuals, però ara es defineix en termes semàntics, en lloc de termes de presentació.
Per canviar l'aspecte de la regla o buits entre ell i els paràgrafs, utilitzeu els fulls d'estil en cascada (CSS).
Categories de contingut | Contingut dinàmic. |
---|---|
Contingut permès | Cap, és un empty element. |
Omissió de l'etiqueta | Ha de tenir una etiqueta d'inici, però no una etiqueta de tancament . |
Elements pares permesos | Qualsevol element que accepti Contingut dinàmic. |
Interfície DOM | HTMLHRElement |
Atributs
Aquest element inclou els atributs globals.
align
- Defineix l'alineació de la regla a la pàgina. Si no s'especifica cap valor, el valor per defecte es
left
. color
- Defineix el color de la regla mitjançant el nom del color o el valor hexadecimal.
noshade
- Estableix que la regla no té ombrejat.
size
- Estableix l'alçada de la regla en píxels.
width
- Defineix la longitud de la regla a la pàgina mitjançant un valor en píxels o percentatge.
Exemple
<p>This is the first paragraph of text. This is the first paragraph of text.
This is the first paragraph of text. This is the first paragraph of text.</p>
<hr>
<p>This is second paragraph of text. This is second paragraph of text.
This is second paragraph of text. This is second paragraph of text.</p>
Sortida del codi HTML anterior:
This is the first paragraph of text. This is the first paragraph of text. This is the first paragraph of text. This is the first paragraph of text.
This is second paragraph of text. This is second paragraph of text. This is second paragraph of text. This is second paragraph of text.
Especificacions
Especificació | Estat | Comentari |
---|---|---|
HTML Living Standard The definition of '<hr>' in that specification. |
Living Standard | Definició de l'element hr |
HTML Living Standard | Living Standard | Suggerit la representació per defecte de l'element hr |
HTML5 The definition of '<hr>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<hr>' in that specification. |
Recommendation | Els atributs align , noshade , size i width estan desaprovats |
Navegadors compatibles
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Suport bàsic | 1.0 | (Yes) | (Yes) | (Yes) | (Yes) |
Característica | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |