Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are H1,H2,H3,H4 tags block or inline elements?

Tags:

html

Is it correct HTML to change the color of text inside a H1, H2, H3 or H4 element? Are they block level?

For example

<h1><span style="color:#ABAB">#500</span> Hello world</h1> 
like image 887
Chris S Avatar asked Oct 28 '10 10:10

Chris S


1 Answers

They are block elements.

If you look at the HTML 4.01 strict DTD:

<!ENTITY % heading "H1|H2|H3|H4|H5|H6">  <!ENTITY % block      "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |       BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS"> 

So, they are all defined as %heading entities, which in turn are part of the %block entities.

As for the question regarding if you can change the color - that's just styling and is fine, though I would do so in a CSS file, not inline:

H1, H2, H3, H4, H5, H6 {  color: #ccccc; } 
like image 162
Oded Avatar answered Nov 10 '22 13:11

Oded