Solved

css float

Posted on 2014-02-21
4
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 30

Expert Comment

by:Britt Thompson
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:
Britt Thompson 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

632 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