467,161 Members | 1,038 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

difference between <h2> and <span>

Hi.. I have a doubt.
I have some code..
<span class="test1">
my screeen

I simply changed it to.
<h2 class = "test1">
my screen

and I see an extra line inserted after my screen in the h2 tag.
I read somewhere that span tag does not consider spaces.
I wanted some help to know the solution to what to add in the <h2> style sheet.
The details of h2 are..

h2.test1 { font-family:'arial','helvetica','chicago';font-weight:800;font-size:10pt;color:${myvariable}; }

do i change sth in this style sheet.
It is mandatory for me to use the h2 tag.

Kind regards,
Please help...
Mar 30 '07 #1
  • viewed: 4578
1 Reply
Expert 2GB
The difference is the display behavior of the two elements you mention: <span> and <h2>

There are two basic types of display properties for HTML elemets: block and inline

<h> </h> is block-level
<span></span> is inline-level

block-level elements will automatically have a line break before and after the content, inline will not. You can change that behavior in the style sheet:

h2.test1 {
font-family: 'arial','helvetica','chicago';
font-weight :800;
font-size: 10pt;
color: ${myvariable};
display: inline;
Mar 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by red | last post: by
5 posts views Thread by garthb@gmail.com | last post: by
5 posts views Thread by nathj | last post: by
reply views Thread by chittu07 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.