error related to incorrect or incomplete html formatting

It's always a struggle when the easy things seem hard and the hard things seem easy!

I'm not sure why I'm having trouble with what should be a simple html and/or css issue, but here I am seeking help.

Take a look at the screenshot to see the visual representation of my problem. It seems like my elements are all over the place despite checking my divs and HTML syntax. The CSS appears to be correct, but I may have missed something in the structure. I need a fresh perspective to spot what I can't seem to see.

Here is the getItem function() that I've added:


function getItem(){
   global $con;
    
    //limit to just getting 6 random products per page
    $get_item = "select * from items order by RAND() LIMIT 0,6";
    $run_item = mysqli_query($con,$get_item);
    
    //using while loop to get multiple data from items table
    
    while($row_item = mysqli_fetch_array($run_item)){
        
        $item_id = $row_item['item_id'];
        $item_cat = $row_item['item_cat'];
        $item_brand = $row_item['item_brand'];
        $item_title = $row_item['item_title'];
        $item_price = $row_item['item_price'];
        $item_image = $row_item['item_image'];
        
        
        echo "
            <div id='single_item'>
                <h3>$item_title</h3>
                <img src='admin_area/item_imgs/$item_image' width='180' height='180'/>      
            ";
    }
}

Click here for a screenshot of the issue.


/* Stylesheet reset borrowed from http://meyerweb.com/eric/tools/css/reset/
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
    display: block;
}

body {background: skyblue;}

.wrapper_main {width:1000px; height:auto; margin:auto; background:black;}
.wrapper_header {width:1000px; height:100px; margin:auto;}


/* Additional styles omitted for brevity */

#footer {width:1000px; height:100px; background:gray; clear:both;}

Answer №1

Here are a few key points to consider regarding the HTML:

Make sure to change <!DOCTYPE> to <!DOCTYPE html>

In line 38, update

<input type="text" name="user_query" placeholder="Search a Product"/ >
to
<input type="text" name="user_query" placeholder="Search a Product" />

You have used the ID cats multiple times -> id="cats". Remember that in HTML, IDs must be unique and only used once per page.


There is also a missing </div> tag in the PHP function:

After this line

<img src='admin_area/item_imgs/$item_image'width=180' height='180'/>
, remember to add the closing element -> </div>

Answer №2

Aside from Simon's response, it seems like there are some floated elements that still need to be cleared. It looks like #sidebar and #content_area have been left uncleared within #content_area. Adding a clear fix at the bottom of #content_area should resolve this issue. It's challenging to assess the content within #content_area since you're working on it locally and we do not have access to inspect that code.

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

Creating a uniform height for images in a Bootstrap 4 carousel across various sizes and screen dimensions

Here is an example of a carousel provided by w3schools: <div id="demo" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ul class="carousel-indicators"> <li data-target="#demo" data-slide-to="0" class="active" ...

Preventing Tabs from Being Clicked Using JQuery

I am new to JQuery and do not have any programming experience, so I am unsure of what changes to make in the script to prevent the "current" tab from being clickable. Below is the script: //When the page loads... $(".thumbCategory").hide(); //Hide all co ...

Stop the div from overflowing

I am currently in the process of developing a unique horizontal animated page transition system which involves scaling the screen to fit the incoming page. However, I have encountered an issue where if the new page is smaller than the previous one, it caus ...

When attempting to display dropdown elements in a Bootstrap navbar on different URLs within a Django project, the elements may not

I'm a newcomer to Django and currently working on developing an app that includes two models, master and details. I encountered an issue with my Bootstrap navbar dropdown while using it on a single base.html file — the dropdown works fine when displ ...

The modal is functioning perfectly with the initial row in the table

Is there anyone who can help me fix this issue? I've spent a lot of time trying different solutions, but none of them seem to work. I'm using a tailwindcss template for the modal and JavaScript to show or hide it. I'm having trouble findin ...

Printing content to an HTML page using Node.js

I'm seeking advice on using Node JS, AJAX, and other related technologies. My goal is to display the content of a JSON file on my HTML page. While I've been successful in saving new objects to the JSON file, I'm struggling to find an effecti ...

Steps for declaring CSS values with fallbacks in case of unsupported values

I'm looking to utilize the overflow: overlay property in Chrome, and overflow: scroll in Firefox. Simply declaring the overlay value causes Firefox not to scroll at all, even though I know it's not standard. My question is: what's the optim ...

Obtain a unique HTML ID dynamically with Selenium and VBA

I am currently working on automating a web form using Selenium and VBA. The form includes a search box that generates an autogenerated list when a value is entered. While I can successfully input a value into the search box and trigger the javascript to cr ...

What is the most effective way to eliminate the title from any tag?

How can I remove the title from only page-1 while using the same structure for both page-1 and page-2? I need to keep the same code structure for both pages, but I want to remove the title that is shown in the hover state. Any help is appreciated. Thanks i ...

Positioning an image so that it is perfectly aligned on top of another image that is centered

http://jsfiddle.net/Weach/1/ The issue at hand involves a background image created using CSS. This image has been center aligned both horizontally and starting from the top, as visible in the provided JSFiddle link. Specifically, there is another image t ...

Can we link together two separate ngfor loops in any manner?

<div class="gl-w-100 gl-md-w-auto gl-po-rel list"> <div class="signin_wrpr gl-w-100 gl-po-rel gl-d-flex gl-fd-column gl-bg-white gl-lg-w-auto gl-md-w-auto gl-h-100 gl-md-ta-c"> <div class="head g ...

Adjust the size of an image and move its position both vertically and horizontally using Javascript

I am currently working on transforming an image both vertically and horizontally, as well as scaling it using JavaScript. While I have managed to resize the image successfully, it doesn't quite look how I want it to. I am aiming for a similar effect a ...

Ways to utilize media queries for repositioning one div on top of another div

Utilizing Bootstrap 5 for website development, my aim is to enhance the responsiveness of the site across various devices. For mobile users, I envision the image-containing div to appear above the div containing the header and paragraph content, but I&apo ...

Creating a toggle button for a div element to expand and collapse its content: Step-by-step guide

For my e-commerce site selling musical instruments, I'm designing a product landing page that showcases guitars, keyboards, violins, and cellos. As part of the design, I want to include expandable sections with detailed information about each instrume ...

Can we incorporate <a> tags in XML as we do in HTML?

Currently, I am honing my XML skills. I am planning to incorporate the <a> tag within the XML file in order to create a hyperlink to another webpage. ...

What is the way to specify both the initial and final classes within a nested class structure?

Within my code, there is a block-border class containing two block-content classes. Specifically, I am working on compatibility with IE9 and higher. I am seeking assistance in defining the structure using Less as shown below: .block-border { &. ...

What causes the disparity in functionality between simple html and css in an Angular 2 project compared to a vanilla html website?

When incorporating the following html/css into a new Angular project created with Angular CLI using 'ng new ProjectName', I encountered issues. Despite adding the CSS to app.component.css or styles.css and the HTML to app.component.html, the Angu ...

Positioning a div within another div using values from a textarea - a step-by-step guide

Check out this script I have: HTML <div id="left"> <div>Orange Div</div> <div> <div class="left_text">top</div> <div class="left_text">left</div> <textarea class="count2"> </textarea& ...

Difficulty encountered while implementing a carousel using HTML, CSS, and JavaScript

I'm currently working on creating a carousel using only HTML, CSS, and JS. While it is functional, it does not perform as smoothly as I had anticipated. After completing one full round of images, there is an approximate 8-second delay before it star ...