Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2012, 12:12 AM   PM User | #1
charisma44
New Coder

 
Join Date: Sep 2012
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
charisma44 can only hope to improve
Image and Text side by side

I have an image and text side by side. I alighned the image to the left and thats fine. How do I get a bit of space between the image and text. The text is on the right side of the image but tight.

Code:
<p><strong><img src="awards2012photo's/Representatives of Adventure Playground at the Forks.png" width="329" height="270" align="left" alt="Parks Canada" /></strong></p>
      <p align="right"><strong>Parks Canada<br />
        Variety The Children’s Charity<br />
        Adventure Playground at the Forks</strong><br />
        Monica Giesbrecht<br />
        Hilderman Frank Thomas Cram Landscape Architects<br />
        Parks Canada.<br />
        Dick Penner J&amp;D Penner Ltd<br />
        Ken Crozier Crozier Enterprises</p>      
      <br>
charisma44 is offline   Reply With Quote
Old 12-10-2012, 12:14 AM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Google css
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 12:17 AM   PM User | #3
charisma44
New Coder

 
Join Date: Sep 2012
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
charisma44 can only hope to improve
i'm sure it's not a css thing. i did it along time ago. it has to do with the html.
charisma44 is offline   Reply With Quote
Old 12-10-2012, 12:23 AM   PM User | #4
resdog
Regular Coder

 
Join Date: Aug 2011
Location: U.S.A.
Posts: 233
Thanks: 2
Thanked 48 Times in 48 Posts
resdog is on a distinguished road
CSS would be the easiest way. Assign the image a class name (like "leftImage") and then assign it a style of margin-right: 10px;

This CAN be done with pure html, by using tables, or by adding non-breaking character spaces (&nbsp, but CSS is a much easier way to go.

If you only have the one image you want to be like this, you can do an inline style, <img src="" style="margin-right:10px"
__________________
WordPress Designer and theme developer. KlongDesigns - helping bloggers and non-technical folks claim their space on the internet.
resdog is offline   Reply With Quote
Old 12-10-2012, 12:27 AM   PM User | #5
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello charisma44,
The html align attribute is depricated and should not be used.

Instead, float your image and the text wraps around it. You can then use margins to make space between them. Look at a simple float tutorial here.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-10-2012, 12:28 AM   PM User | #6
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by charisma44 View Post
i'm sure it's not a css thing. i did it along time ago. it has to do with the html.
Html is presentation. CSS is styling. The space you want is definitely a CSS thing.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-10-2012, 01:06 AM   PM User | #7
charisma44
New Coder

 
Join Date: Sep 2012
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
charisma44 can only hope to improve
The image has to stay left. and can't wrap text around. Text needs to stay to the right.
charisma44 is offline   Reply With Quote
Old 12-10-2012, 01:41 AM   PM User | #8
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by charisma44 View Post
The image has to stay left. and can't wrap text around. Text needs to stay to the right.
Float is what you want. Did you look at the tutorial I suggested?

Sometimes, like when it's a caption or product description, it all needs wrapped in a containing element to keep things together. Look at this demo of how easy captions can be.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-10-2012, 01:44 AM   PM User | #9
charisma44
New Coder

 
Join Date: Sep 2012
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
charisma44 can only hope to improve
yes. and still trying to figure it out. i tryed the css the way the other guy said and it didn't make it worse and didn't make it better. still reading.
charisma44 is offline   Reply With Quote
Old 12-10-2012, 01:54 AM   PM User | #10
charisma44
New Coder

 
Join Date: Sep 2012
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
charisma44 can only hope to improve
Ok we got it now. Thanks alot.
charisma44 is offline   Reply With Quote
Old 12-10-2012, 02:06 AM   PM User | #11
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
So, the snippet you posted... I'm not sure why you wrap an image in paragraph tags or why the strong tag too...

"The <em>, <strong>, <dfn>, <code>, <samp>, <kbd>, and <var> tags are all phrase tags. They are not deprecated, but it is possible to achieve richer effect with CSS." See http://www.w3schools.com/tags/tag_phrase_elements.asp

Either way, it's nothing to do with the image.


Following my demo, look at it with floats instead, something like this -
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
	margin: 0;
	background: #fc6;
}
#container {
	width: 800px;
	margin: 30px auto;	
	padding: 200px 0 300px;
	background: #fff;
	box-shadow: 0 0 20px #8493A6;
	overflow: auto;
}
.wide_wrapper {
	width: 500px; /*adjust width to suit*/
	margin: 50px 0 0 150px;
	overflow: auto;
	text-align: left;
	border: 1px solid #F00;
	font-size: 0.7em;
}
.wide_wrapper img {	
	float: left; 
	margin: 5px; /*adjust space to suit*/
	background: #eee; 
}
</style>
</head>
<body>
    <div id="container">
        <div class="wide_wrapper">
            <img src="awards2012photo's/Representatives of Adventure Playground at the Forks.png" width="329" height="270" alt="Parks Canada" /> 
                <h3>Parks Canada</h3>
                    <p>  
                        Variety The Children’s Charity<br />
                        Adventure Playground at the Forks</strong><br />
                        Monica Giesbrecht<br />
                        Hilderman Frank Thomas Cram Landscape Architects<br />
                        Parks Canada.<br />
                        Dick Penner J&amp;D Penner Ltd<br />
                        Ken Crozier Crozier Enterprises</p>      
                    </p>
        <!--end wide_wrapper--></div>    
    <!--end container--></div>
</body>
</html>
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-10-2012, 02:32 AM   PM User | #12
charisma44
New Coder

 
Join Date: Sep 2012
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
charisma44 can only hope to improve
I got the look I was going for. Tell me what you think

http://www.aacwinnipeg.mb.ca/awards2.html
charisma44 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:32 AM.


Advertisement
Log in to turn off these ads.