floating image after text even when the text wraps

Posted on 2014-01-08
Medium Priority
Last Modified: 2014-01-15

I need an image to float right of a headline even when the text in the headline wraps onto another line.

<div style="width:100px">
<h3 style="float: left">headline text</h3>
<span stlye="float:left">background image placeholder</span>

At the moment I am having issues if the text wraps onto a new line the image no longer sits to the right of the text but instead sits underneath it. If the text is in one line it looks fine.


Attached is a schematic example of what I need
Question by:Al4ddin2

Accepted Solution

Adrian Crabtree earned 1000 total points
ID: 39765965
Hi Al4ddin2, you can try setting the H3 to a display: inline. Here's a pen I created to illustrate that idea.

LVL 58

Assisted Solution

Gary earned 1000 total points
ID: 39765969
Since you are setting the container to width:100px there is no room for the image to float next to the text. An inline element will take up as much room as it needs - in this case the whole 100px before wrapping.
To get them on the same line you need to give the H3 tag a set width that allows enough room for the image to fit into the remaining width of the container

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
There's never been a better time to become a computer scientist. Employment growth in the field is expected to reach 22% overall by 2020, and if you want to get in on the action, it’s a good idea to think about at least minoring in computer science …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question