Tips for utilizing the div tag in a similar manner as a table

How can I position the div tag to resemble a table in the correct order?

<html>
<head><title> .</title>
<link rel="stylesheet"  type="text/css" href="style/main.css"/>
<script type="text/javascript" src="script/ajax.js"></script>
 <script type="text/javascript" src="script/validate.js"></script>
<script type="text/javascript" src="script/date-picker.js"></script>
</head>
<body>
<div onclick="show_tb()" style="width:70%;float:left;" class="title_mrwat" >

NEW MARWAT OIL TRANSPORTER
</div>
<div style="width:30%;float:right;">
<address>
Address:P/O Box 564, Landekotal Peshawar<br />
Phone: +12 34 56 78
</address>

</div>

<div style="width:50%;float:left;">
<img src="images/pso.jpg" height="45" width="45" />
<img src="images/total.jpg" height="50" width="55" />
<img src="images/shell.jpg" height="50" width="45" />
<img src="images/caltex.jpg" height="35" width="35" />
<img src="images/attock.jpg" height="40" width="40" />

</div>


<div style="width:50%;float:right;" id="tb">
<input type="button" value="product" onmouseover="className='menuon';" onmouseout="className='menuoff';" onclick="loadXMLDoc('product/','formTag' ,'')" value="product">
<input type="button" value="owner" onclick="loadXMLDoc('owner/','formTag')" value="shipment" onmouseover="className='menuon';" onmouseout="className='menuoff';">
<input type="button" onclick="loadXMLDoc('vehicle/','formTag')" value="vehicle" onmouseover="className='menuon';" onmouseout="className='menuoff';">
<input type="button" onclick="loadXMLDoc('route/','formTag')" value="route" onmouseover="className='menuon';" onmouseout="className='menuoff';">
<input type="button" value="shipment" onclick="loadXMLDoc('ship/','formTag')" value="shipment" onmouseover="className='menuon';" onmouseout="className='menuoff';">
<input type="button" id="bt" value="report" onclick="show_form()" style="background-color:#E6E6DC;" >
</div>

<div id="responseTag" class="show_rpt" style="width:100%;">

</div>

<div id="div_added" class="div_add">
</div>
<div id="formTag">


</div>


</body>
</html>

Answer №1

Ensure all divs have the same float direction.

<div style="width:50%;float:left"> first </div>
<div style="width:50%;float:left"> second </div>

When using the above code, two divs will be floating. However, it's important to note that setting width to 50% may not always work as expected. Additionally, you'll need to use clear: left/right/both to break the floating after each "row".

Answer №2

To modify the layout of the <div> element, you can utilize CSS

display:table;

By default, the <div> is a block-level element in CSS

display:block;

If you want to structure your content like a table, consider using nested <div>'s for <tr> and <td> elements

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Leverage variables in mixins and extends within Less.js

When using a variable with mixin or extend in Less.js, the following code will result in an error: @bar : bar; .@{bar} { background: yellow; } // ParseError: Missing closing ')' .foo { .@{bar}(); } // This will not work .jam { &:ex ...

Stopping the parent onclick event from propagating to a child element within a bootstrap modal

I am currently working with angularjs and bootstrap, incorporating nested onclick events using Angular's ng-click in various HTML elements. One is located in a table header to display different sort icons and execute the sorting logic when the header ...

Tips for adjusting image dimensions to accommodate small and large screens

Is there a way to make an image adapt to both mobile and full screen sizes? I attempted to make some adjustments, but unfortunately, I wasn't successful. The div class in question has a fixed width and height: <div class="pull-left thumb-con ...

The process of sending a POST parameter to a page in PHP and opening it

When attempting to open a page using PHP, such as: $html = file_get_contents('https://hammihan.com/search.php'); I encountered an issue where the page was being redirected to https://hammihan.com/users.php due to an empty input for name. To addr ...

What causes a fixed position div to extend beyond the boundaries of the main container?

Below is the CSS for the fixed div: .top-container { position: fixed; width: 100%; z-index: 999; } Upon zooming out the screen, the div causes the main container to break on the right side while the left side remains unchanged. Refer to the screenshot be ...

Content on the website has vanished into thin air

Attempting to retrieve the content of a webpage located at The source code of this page reveals an element labeled "row_1"... However, when attempting to achieve this in my code: reader = new BufferedReader(new InputStreamReader(connection.getInputStrea ...

View content from a text file on a webpage

Hi everyone, I could really use some assistance with a project I'm currently working on. As someone who is new to programming, I am facing a challenge. My goal is to showcase the contents of a plain text file on a webpage. This text file, titled titl ...

Customize jQuery mobile listview with large headers

Currently, I am making use of the basic list feature in jQuery mobile to showcase a list of products. However, when there are too many characters in the h3 title, it gets snipped and displayed with "..." at the end. Is there a way to display the complete h ...

Ways to customize the appearance of the Next/Prev Button in Griddle

Here is the scenario that has been implemented: nextClassName={'text-hide'} nextText={''} nextIconComponent={ <RaisedButton label='Next' />} As a result, a Next Button with a wrapper div above the but ...

The Bootstrap Carousel unfortunately does not provide the option for responsive images

There appears to be an issue with the bootstrap carousel images where they are being assigned a fixed height/width attribute by either views or bootstrap_views. As a result, when the page is resized or viewed on a smaller screen or device, the image gets ...

Encountering a 404 error while trying to use the autolinker

I have been struggling with this issue for the past day and can't seem to solve it on my own. Essentially, I am attempting to use Autolinker.js to automatically convert URLs into clickable hyperlinks in my chat application. However, every time I try ...

How to position a full-width banner image in the center using CSS without causing scrollbars

I am facing a design challenge with my webpage where the content is 1000px wide. In the middle of this page, I want to showcase an image that is 600px high and 2000px wide. The tricky part is ensuring that this image remains 600px high, maintains its aspe ...

Troubleshooting the issue of CSS animations activating twice and causing a flickering effect specifically in the Firefox browser

I am facing an issue with CSS animations in Firefox. When I try to slide in some radio buttons upon clicking a button, the animation seems to be firing twice in Firefox while it works fine in Chrome. I have attempted several solutions but haven't been ...

Utilizing checkboxes to dictate PHP and MySQL queries

Seeking assistance with MySQL, jquery and PHP. Here is the code provided: HTML <label class="checkbox"><input type="checkbox" name="code_site1" class="code_site1" checked="checked">Code 1</label> <label class="checkbox"><input ...

Element remains stationary and covers full viewport on mobile devices when the page overflows

I am looking to create a fixed element that covers the entire viewport on mobile devices (specifically Chrome and WebView). The CSS code I have is very straightforward: .full { position: fixed; left: 0; top: 0; width: 100vw; height: 10 ...

"Components in Vue remain consistent in their behavior regardless of the various calls made to

I am attempting to create a Vue component that displays an image, opens a modal with a second image, and then replaces the first image with a third one. The first and third images work as intended, but the image in the modal never updates. It keeps reusing ...

Angular ng-repeat failing to display data as expected

I've been attempting to create a table from a JSON structure, but I'm having trouble getting it to display correctly. The output is not appearing as expected for the first two cells; "Partial" is empty and only filling the last one. You can see ...

Using jQuery to retrieve the domain extension from a URL

Seeking assistance with extracting domain extensions from various URLs using jQuery. Uncertain how to account for all possible scenarios. Here are the parts of the URL that need to be extracted: https://www.amazon.**com**/dp/067144901X https://www.amazon. ...

What is the best way to acquire an ID that is generated dynamically?

Being new to javascript and ajax, I am facing a challenge. I have a while loop with 2 buttons, both of which seem to function correctly, except for one small issue... The product-id is only being passed for the first or last element in the loop. How can I ...

Utilize socket.io to send information from a nodejs server to an html webpage

I've been working on transferring data from Node.js to HTML using socket.io. Initially, I successfully transferred text from Node.js to HTML with the following code: Node.js code : app.post('/timer', function(req, res){ ...