Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Need help putting 2 div tags side by side
Old 10-08-2010, 03:48 AM Need help putting 2 div tags side by side
Banned

Posts: 408
Name: mushget
Trades: 0
First off, yes I read the FAQs, scoured the internet for solutions, etc. I also found several solutions to this problem, however I have not been able to get any of them to work. I'm a CS student at a university, but have very little experience with web development, so I decided to build a website for myself from scratch to get some hands on experience.
Here is the problem: I need to put 2 div tags side by side. Float:left, clear:both, and any number of other solutions I have found though google have failed me. I feel like I have to be missing something incredibly elementary, but these tags will not sit next to each other.
Code:
<html>
	<body>
		<div style = "width: 100%;">
			<div stlye = "width: 10%; float:left;">
				Name:<br>
				Comment:
			</div>
		
			<div style = "width: 70%; float:left;">
				<form action = "comment.php" method = "post">
				<input type = "text" name = "name" size = "57">
				<input type = "submit" value = "submit"><br>
				<textarea cols = "50" rows = "6" name = "comment"></textarea>
			</form>
			</div>
			<div style = "clear:both;"></div>
		</div>
	</body>
</html>
As you can see, I've tried making the 2 div tags smaller than 100% width in an effort to make them fit on the same line, added a "clear:both" div tag as indicated by several forum posts on other websites, and this is still the end result.


I apologize in advance if I come off sounding ungrateful or snobbish; I'm just feeling like an idiot right now because I can't figure out how to get something so simple to work properly.
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
 
Register now for full access!
Old 10-08-2010, 04:19 AM Re: Need help putting 2 div tags side by side
Junior Talker

Posts: 2
Trades: 0
as a start, just add

div
{
float:left;
}

and see what you get. if that doesnt work, get rid of the containing div and then see what it looks like
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
aslef is offline
Reply With Quote
View Public Profile
 
Old 10-08-2010, 07:24 AM Re: Need help putting 2 div tags side by side
Junior Talker

Posts: 2
Trades: 0
You have a spelling mistake in your code to start with, try it with it fixed.

<html>
<body>
<div style = "width: 100%;">
<div stlye = "width: 10%; float:left;">
__________________

Please login or register to view this content. Registration is FREE
Web Design is offline
Reply With Quote
View Public Profile Visit Web Design's homepage!
 
Old 10-08-2010, 08:55 AM Re: Need help putting 2 div tags side by side
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Fixing the typo will fix your problem as noted above.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 10-11-2010, 08:57 PM Re: Need help putting 2 div tags side by side
Banned

Posts: 408
Name: mushget
Trades: 0
Thanks guys.
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Old 10-13-2010, 01:28 PM Re: Need help putting 2 div tags side by side
captkrackerjack's Avatar
Experienced Talker

Latest Blog Post:
Moved Blog to NGINX!
Posts: 31
Name: Greg
Location: California
Trades: 0
For a quick recommendation, place all the style into your header instead of inline on the elements. This will make your code a bit cleaner as well as making it easier to avoid such mistakes. Since there will be less points of failure as well as allowing easier reuse of code. The best solution overall is to use external style sheets but for testing and learning using embeded stylesheets is okay.

So your code would look like this using the method I suggest.
Code:
<html>
 <head>
  <title>Document</title>
  <style type="text/css">
   .float {
        float: left;
   }
   .clear {
       clear: both;
   }
   #container {
       width: 100%;
   }
   .left_width {
       width: 10%;
   }
   .right_width {
       width: 70%;
   }
  </style>
 </head>
 <body>
  <div id="container">
   <div class="left_width float">
        Name:<br>
        Comment:
   </div>
 
   <div class="right-width float">
    <form action = "comment.php" method = "post">
     <input type = "text" name = "name" size = "57">
     <input type = "submit" value = "submit"><br>
     <textarea cols = "50" rows = "6" name = "comment"></textarea>
    </form>
   </div>
   <div class="clear"></div>
  </div>
 </body>
</html>
Check out w3schools.com this is a great resource for learning web languages. Finally look into web standards as well I know you are learning but learn the right way from the beginning, I see use of <br> tags which, in my opinion shouldn't be used as well.

P.S. The code I provided hasn't been tested but its to get the general idea of how to better use CSS. There are also use of classes and id's so again read up on it but learn it this way since its far better off for you.
__________________

Please login or register to view this content. Registration is FREE

Fav sites; last.fm, mashable.com, speckyboy.com
captkrackerjack is offline
Reply With Quote
View Public Profile Visit captkrackerjack's homepage!
 
Reply     « Reply to Need help putting 2 div tags side by side
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.09183 seconds with 12 queries