General HTML/Web Design Programming Q`s/Inline vs Block Tags

Advertisement


Question
Hi John

I am confuse over the idea of block and inline tags? Can you provide me with a simple explanation.

In addition, if I have multiple <img> that I want to format differently in CSS. Can I place an <img> tag inside a <div> tag like <div id="pic1"><img src "aaaaa.png"/></div> to split each of them up in XHTML 1.0.

Many Many Thanks,
Sam

Answer
These two questions are actually related.  To answer the first one...

Some examples of block level elements include: div, h1, p, and hr HTML tags.

Some examples of inline level elements include: a, span, strong, em, b, and i HTML tags

Basically a block element is one that provides content at full width with a linespace above and below the content.  An inline element is one that simply displays content right along with the previous content on the page without skipping a line ot adding a line after it.

As per your second question...

Adding div tags will utilize the block structure.  But technically it is okay to use div tags around the img tags as you specified as long as you keep the following in mind.

If you want the images to interact in the same way as if there were no block elements applied to it (in other words, if you want the img tags to remain inline), then you want to make sure to add the following css rule for <div id="pic1">...

#pic1 {
display: inline;
}

But you'll leave it alone or add display:block if you want each div to give a space before and after itself (like a paragraph).

General HTML/Web Design Programming Q`s

All Answers


Answers by Expert:


Ask Experts

Volunteer


John Martin

Expertise

I am able to answer any web design related questions including but not limited to html, dhtml, xml, wml, css, php, flash, swf and WAP. I have computers and electronics experience dating before the Military where I served as a tactical telecommunication com center operator in Military Intelligence during Desert Storm (and Desert Shield). I have a total of 22 consecutive years of computer experience (since age 14) and also teach computer classes locally. I also know little known secrets to making money online and SEO.

http://www.versitek.com

Experience

22 years of consecutive computer related jobs, hobbies and Military operations.

Education/Credentials
Personal experience, US Military Intelligence experience, Schooling and Signal Corp. Training as well.

Awards and Honors
Army accommodation medal and a two week advancement in A.I.T. training due to already existent computer knowledge at the time.

©2016 About.com. All rights reserved.