By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,676 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,676 IT Pros & Developers. It's quick & easy.

difference between <h2> and <span>

P: 1
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
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 4,059
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.