Topic: Use of <span>

I thought that if I had an image in a DIV, followed by some text I could surround the contents of the DIV with span to maintain the flow, as opposed to having the text below.

<div id='header'>
    <span>
        <img src="myImage.png" alt="picture"></img>
            <h1> The Title of My Web Page</h1>
    </span>
</div>

When I do the above, the <h1> is under the image and my editor suggest something is askew.

Vote up Vote down

Re: Use of <span>

You might need to clarify what you mean when you say you want to "maintain the flow." I'm not sure how/why you would use a <span> tag in that way... That isn't how it's supposed to be used. A span tag is similar to a div, except that it displays inline, rather than block (which forces elements within it down to a new line). http://www.w3schools.com/TAGS/tag_span.asp
http://www.w3schools.com/css/pr_class_display.asp

The only way to move the h1 above the image is to move the code, so that the h1 is above the image within the code, or to use absolute positioning on the h1 to move it into position (which I wouldn't recommend).

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Use of <span>

If you are wanting to have the h1 to the right of the image, you'd need to do that by floating either the image (floating the image left) or the h1 (floating it right), or floating both left. Both the h1 and the image use display:block, so they are going to display on their own lines unless you change that by floating them or using absolute/relative positioning.

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Use of <span>

The "above" refers to the code above the sentence.  I want it to be inline and not block.

Vote up Vote down

Re: Use of <span>

OK! thanks, that makes sense. let me try to do that.

Vote up Vote down