Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple lines of text next to image (CSS-HTML)

I am trying to put 2 lines of text next to an image, sort of like this

_________ |       | Line one of text | image | |       | Line two of text --------- 

This is the code that I have so far

<p style="color: #fff;"><img src="assets/image.png"><span style="">Line one of text</span>     <br>     <span class="ban2">Line 2 of text</span></p> 
 .banner p {   font-family: "Gentium Basic";   font-size: 19px;   text-align: center;   color: #aaa;   margin-top: -10;   display: block;  } .banner img {   float: center;      margin: 5px;  }  .banner span {   padding-top: 50px;   font-size: 17px;   vertical-align:top;  }   .banner .ban2 span {   padding-top: 50px;   font-size: 17px;   vertical-align:top;  } 

But currently it does this:

_________ |       | Line one of text | image | |       |  --------- Line two of text 

I have looked all over the web but have not been able to figure out how to do this, any help would be very welcome.

like image 607
OstlerDev Avatar asked Dec 05 '13 04:12

OstlerDev


People also ask

How do I format text next to an image in HTML?

in order to have text on the left or right of the image you can style your img as style="float:left"; or style="float:right"; If the text is too close to the image you can play with padding: 10px; or less.

How do I show multiple lines of text in HTML?

To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.

How do I put text and pictures side by side in HTML?

Use the markup code <BR CLEAR=”left” /> to flow text around images on opposite sides of your Web pages. One of the first things you may want to do is place an image on the page.


2 Answers

There's no such thing as float: center; You can choose either left, right, or none.

http://jsfiddle.net/vd7X8/1/

If you float: left; on the image it will do what you're after.

If you want it centered, then you're going to have to wrap the image and the text in a container, fix the width of the container and do margin: 0 auto; on it, then continue to have your image floated--except it will be constrained by the wrapper.

like image 138
Ming Avatar answered Nov 06 '22 23:11

Ming


Here is a snippet using a svg so you can test it anywhere.

.img{      float: left;      margin-right:1rem;  }
<div>    <svg class="img" width="50" height="50" >      <rect width="50" height="50" style="fill:black;"/>    </svg>    <p>      Line 1      <br>      Line 2    </p>  </div>
like image 41
mvndaai Avatar answered Nov 06 '22 23:11

mvndaai