Solved

css float

Posted on 2014-02-21
4
238 Views
Last Modified: 2014-02-21
HI,

I have the following code

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Documento sin título</title>

<link href="test.css" rel="stylesheet">

</head>

<body>
<table width="350" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<form id="form1" name="form1" method="post">
  <label for="textfield">Text Field:</label>
  <input type="text" name="textfield" id="textfield">
  <label for="email">Email:</label>
  <input type="email" name="email" id="email">
  <label for="password">Password:</label>
  <input type="password" name="password" id="password">
</form>
<p>&nbsp;</p>
</body>
</html>

Open in new window


and for css
@charset "UTF-8";
/* CSS Document */
#form1{
	float:right'
}

Open in new window


I want the form appears to the right of the table
0
Comment
Question by:joyacv2
  • 2
  • 2
4 Comments
 
LVL 30

Expert Comment

by:renazonse
ID: 39878021
you need to surround your table with a div and then you have to set the widths on the divs. If you don't set the widths it doesn't know where to float.
0
 
LVL 1

Author Comment

by:joyacv2
ID: 39878034
updated code, don't work

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Documento sin título</title>

<link href="test.css" rel="stylesheet">

</head>

<body>
<div width="300px">
<table width="350" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table></div>
<form id="form1" name="form1" method="post">
  <label for="textfield">Text Field:</label>
  <input type="text" name="textfield" id="textfield">
  <label for="email">Email:</label>
  <input type="email" name="email" id="email">
  <label for="password">Password:</label>
  <input type="password" name="password" id="password">
</form>
<p>&nbsp;</p>
</body>
</html>

Open in new window

0
 
LVL 30

Accepted Solution

by:
renazonse earned 500 total points
ID: 39878071
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Documento sin título</title>

<link href="test.css" rel="stylesheet">
<style>
/* CSS Document */
#container { width:525px; margin: 10 auto 0 auto; }
#theTable { width:350px; float: left; }
#theForm{
	float:right;
	width:150px;
}
</style>
</head>

<body>
<div id="container">
<div id="theTable">
<table width="350" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table></div>
<div id="theForm">
<form id="form1" name="form1" method="post">
  <label for="textfield">Text Field:</label>
  <input type="text" name="textfield" id="textfield">
  <label for="email">Email:</label>
  <input type="email" name="email" id="email">
  <label for="password">Password:</label>
  <input type="password" name="password" id="password">
</form>
</div>
<p>&nbsp;</p>
</div>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 39878128
works perfect!!!!!!!!!!!!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using jQuery to set a DIV attribute on page load 9 29
Converting dates in JavaScript 2 31
Change Background Color of Website 5 14
Bottom border change 5 13
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

815 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now