?
Solved

Div Tag in HTML

Posted on 2010-11-30
11
Medium Priority
?
312 Views
Last Modified: 2012-06-27
I would like to have 2 div tags as like table columns in my page.

Can someone share your knowledge to do this?

Thanks in advance
0
Comment
Question by:czutshi
[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
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 2

Expert Comment

by:Jogai
ID: 34238589
0
 
LVL 19

Accepted Solution

by:
Bardobrave earned 668 total points
ID: 34238760
Try this:

<div width="49%" style="float:left;"></div><div width="49%" style="float:left"></div>

width at 49% for every div make them to fit both together on your page, float left style make them behave as inline elements, don't making second one to jump into new file.
0
 
LVL 16

Expert Comment

by:s8web
ID: 34239765
Hi Czutshi - I know you said two divs, but you will need a little more than that. Here is an example as to how to replicate a table with divs.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Divs like a table</title>
<style type="text/css">
#holder{
	width:700px; /*If this were a table, this would be the table tag - so define the width here in px or %*/
	}
.column{
	float:left;
	width:50%
	}
.cell{
	border:solid #ebebeb;
	border-width:0 1px 1px 1px;
	}
.cell:first-child{
	border:solid #ebebeb;
	border-width:1px 1px 1px 1px;
	}
.clear{clear:both;}
</style>
</head>

<body>
<div id="holder">
	<div class="column">
		<div class="cell">Column 1</div>
		<div class="cell">&nbsp;</div>
		<div class="cell">&nbsp;</div>
		<div class="cell">&nbsp;</div>
	</div>
	<div class="column">
		<div class="cell">Column 2</div>
		<div class="cell">&nbsp;</div>
		<div class="cell">&nbsp;</div>
		<div class="cell">&nbsp;</div>
	</div>
	<div class="clear"></div><!-- This needs to be last to clear your floats. Otherwise some ugly things can happen. -->
</div>
</body>
</html>

Open in new window

0
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 8

Assisted Solution

by:Zado
Zado earned 668 total points
ID: 34240634
Depends what you want to have in those columns, if it's text columns, you can use very simple css code (css3):

in <head> section:
<style type="text/css">  
.columns {  
  -moz-column-count: 2;  
  -webkit-column-count: 2;  
}  
</style> 

Open in new window



in <body> section:
<div class="columns">  
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>  
  <p>Lorem ipsum dolor sit amet.</p>  
</div>

Open in new window


Css3 is a very powerful tool in web design, the only defect is, it doesn't work properly in old browsers.
Read about css3 tricks here: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/CSS/A_4168-New-CSS-techniques-with-CSS3.html?sfQueryTermInfo=1+30+css
(the article will be improved very soon)
0
 
LVL 16

Expert Comment

by:s8web
ID: 34240754
CSS3 columns don't work in IE7 or 8 which unfortunately is most browsers.
0
 
LVL 8

Expert Comment

by:Zado
ID: 34241090
True, and unfortunately IE is used by most people, worst browser ever and nightmare for web designers :-/
There's a lot of things work fine in every browser except IE.
0
 
LVL 2

Assisted Solution

by:Manidf
Manidf earned 664 total points
ID: 34247004
Try this out. i use this technique often.

1. have containing div #row (give this div a width say 600px)
2. inside of #row insert as many divs as you need. apply the "float: left; rule to them,
    ensure that the divs placed inside all cumulatively equal the width of the containing div being #row
    in this case i have 3 divs so they each are 200px wide.
3. you can place as many row divs below as you like. make sure to add "clear: both" to the .row div when stacking them so that they stack one on top of each other.

4. to note one can add a multitude of class names for styling to one div element. so i recommend using CLASS and not ID.  <div class="column green big"></div>
divs.html
0
 
LVL 2

Expert Comment

by:wasim117
ID: 34247196
You can use display:cell css property for
0
 
LVL 8

Expert Comment

by:Zado
ID: 34317461
Please grant the points and close the question, thanks :-)
0
 
LVL 8

Expert Comment

by:Zado
ID: 34384897
Please let us know if any solution provided works for you, otherwise we will continue work on your problem and try to find best possible solution, thanks.
0
 
LVL 2

Expert Comment

by:Manidf
ID: 34391793
Hi hows it going on this have you come to a resolution? take car. Manidf :-)
0

Featured Post

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
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 code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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…
Suggested Courses

752 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