Jump to content

I am a beginner at css and need to float one img to the right but not the other two how do I do it?


Wolverine

Recommended Posts

As an example here is my code so far:

<!DOCTYPE html><html lang="en">  <head>	<meta charset="utf-8">	<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">	   <meta name="description" content="">	<meta name="keywords" content="HALLOWEEN">	<title>HAPPY HALLOWEEN</title>  	<style type="text/css">	<!--	body {	  color:#FFFFFF;	  background-color:#000000;	}	a  { color:#FFFF00; }	a:visited { color:#00FFFF; }	a:hover { color:#00FF00; }	a:active { color:#FF0000; }h1 {text-align:center;}h2 {text-align:center;}p {text-align:left;}p {text-indent:50px;}	-->	</style><style>p.one{border-style:solid;border-width:3px;}h1.four{border-style:inset;border-width:medium;border-color:red;}</style>	<!--[if IE]>	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>	<![endif]-->  </head>  <body><img src="halloween34.gif" width="129" height="200" alt="HAPPY HALLOWEEN" title="HAPPY HALLOWEEN"  style="border:0px solid black" /><h1>HAPPY HALLOWEEN</h1><h2>From Mark's PLACE</h2><img src="halloween54.gif" width="75" height="169" alt="Candle burning on a Jack O Lantern" title="Candle burning on a Jack O Lantern" style="border:0px solid black"  align="right" /><p class="one">Hi, my name is Mark Nelson and I am a Trekker, I am interested in Star Trek, Star Wars, Science Fiction Books, Movies and TV Shows, and NEVERWINTER  NIGHTS . If you are a Trekker please come here and let's stay in touch. If you are not a Trekker that is good as well. If you have some constructive criticism that will help me improve this site that is superb. I am currently trying to make a Christmas themed version of this site as well.Then if I succeed at that I will start working on an Easter themed version.</p><br /><br /><br /><br />  <P> </P>  <h1 class="four">Hobbies and Interests</h1><P class="one">My Hobbies are computers, reading Science Fiction Books, playing NEVERWINTER NIGHTS and the Internet. I hope all the fans of Star Trek and NEVERWINTER NIGHTS will come here and tell me how they like my site. Live long and Prosper! If you like reading online stories I have some that I have written myself on the next page of this site and on the page after that download links for the text file versions.</P><img src="halloween7.gif" width="216" height="144" alt="HAVE A HAUNTINGLY GOOD HALLOWEEN!" title="HAVE A HAUNTINGLY GOOD HALLOWEEN!" style="border:0px solid black" />  </body></html>

What I want to do is float halloween54.gif to the right side of the page but not the other two. Any ideas what I should do?

Edited by Wolverine
Link to comment
Share on other sites

For a really simple way to do it, you could just add float: right; to the halloween54.gif image with the inline styling. Like this: <img src="halloween34.gif" width="129" height="200" alt="HAPPY HALLOWEEN" title="HAPPY HALLOWEEN" style="border:0px solid black; float: right" /> As your pages grow though, you might find that inline CSS makes your code too bloated and hard to manage. It would be better to add class="alignright" to the <img> element and in your stylesheet specify:

.alignright { float: right; }

This means you can add class="alignright" to anything you want to float and prevents unnecessary markup. Read these: http://www.w3schools.com/css/css_howto.asphttp://www.w3schools.com/css/css_id_class.asp

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...