Using either the <h1> or <p> tag within my <div> element disrupts the entire layout

Whenever I add a heading tag or paragraph tag within my div, it causes the content to drop down the screen significantly. I am unsure of the cause and feel a bit overwhelmed by it. I attempted to wrap the <h1> tag in a <div>, as shown below:

<div class="left">
<div>
<p>hello</p>
</div>
</div>

Unfortunately, this did not solve the issue, so any guidance would be greatly appreciated.

Below is a simplified version of the code, or you can view it on jsFiddle:

View the simplified version of the problem on jsFiddle

index.html

<div class="wrapper">
    <div class="header">
        <div class="wrap"> <span class="img_1"><img src="imgs/sjplogo.png" id="sjplogo"/></span>

             <h2>Website Service</h2>
 <span class="img_2"><img src="imgs/sslogo.png" id="sslogo"/></span>

        </div>
        <div class="maincontent">
            <div class="maincontentWrapper">
                <div class="topWrapper">
                    <div class="left"><p>hello</p></div>
                    <div class="center"></div>
                    <div class="right"></div>
                </div>
                <!--End topWrapper-->
                <div class="bottomWrapper">
                    <div class="leftBottom"></div>
                    <div class="rightBottom"></div>
                </div>
                <!--End bottomWrapper-->
            </div>
            <!-- End maincontentWrapper-->
        </div>
        <footer></footer>
    </div>

css/style.css

@charset"utf-8";

/* CSS Document */

/********************************
* CSS Reset                     *
*********************************/
 ... (CSS styles omitted for brevity) ...

Answer ā„–1

Applying vertical-align:top to the inline-block elements led to a successful outcome.

.right {
    width:200px;
    height:200px;
    background-color:black;
    display:inline-block;
    margin-right:20px;
    vertical-align:top;
}

Visit this link for more information.

Here is an explanation from this source:

The baseline of an 'inline-block' is determined by the baseline of its last line box in the normal flow, unless certain conditions are met, in which case the baseline is the bottom margin edge.

Answer ā„–2

Utilizing floats for topWrapper child elements http://jsfiddle.net/Ak6jP/

.left { 
  width:200px; 
  height:200px; 
  float: left; 
  background-color:red; 
  display:block;
  margin-right:20px;
 }

.center {
  width:200px;
  height:200px;
  float: left;
  display:block;
  background-color:blue;
  margin-right:20px;
}

.right {
  width:200px;
  height:200px;
  float: left;
  background-color:black;
  display:block;
  margin-right:20px;
}

Consider utilizing the modern flexbox layout method as well: http://css-tricks.com/snippets/css/a-guide-to-flexbox/

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

What is the best way to align the bottom of the last child of a flex element?

Current: https://i.sstatic.net/e7V8x.png Desired: https://i.sstatic.net/Xszod.png Is it possible to achieve this using the flex or grid model, or do I need to reconsider the structure with a different approach? Below is the code snippet: .sections { ...

Can the JavaScript code be altered within the client's browser?

So, I'm using JQuery Validator on my webform to validate form data. However, I haven't added any validation on the server side. I'm curious if it's possible for a user to modify the code and bypass my validations in their browser. If th ...

Universal compatibility for web displays

I've been conducting testing on a website across Chrome, Firefox, and Internet Explorer, utilizing the CSS code snippet below: #foot_links1, #foot_links2, #foot_links3 { position: absolute; margin-top: 55px; margin-top: 14em; color: # ...

Creating a split-view menu in WinJS: A step-by-step guide

I'm attempting to create a versatile app using JavaScript. I followed a tutorial on the MSDN website, but for some reason, the "nav-commands" class isn't displaying when the splitview is opened. I have set closedDisplayMode = 'none'. & ...

If element Div is labeled as either A, B, or C, it should smoothly fade out and then fade in as Div

I'm currently working on enhancing the navigation of my portfolio website and Iā€™m facing a challenge in adding additional properties to my toggle() function. This basically involves creating a filter system with four possible options, which are: ...

Ensuring Consistent TD Heights in Email Designs

I am currently facing a challenge in building an HTML email, specifically in ensuring that two TD elements have the same height across all email clients. Since it is a responsive email design, I have opted to separate the columns into two tables instead o ...

Is there a way to hide a button on this virtual keyboard after it has been clicked?

After creating a virtual keyboard using HTML and CSS, I am looking to implement JavaScript code that will hide a button after it is clicked. Here is the code I have tried so far: function hideButton() { var button = document.getElementById("simple_butto ...

Controller for Ionic 3 styles and loading animations

What is the best way to eliminate these white spaces in our fullscreen mode? View the image here removeWhiteSpace() { let space = document.getElementById('white-space'); if (space) { space.style.display = 'none'; ...

Troubleshooting a Windows Phone HTML5 app encountering an Ajax error

Currently, I am working on developing a Windows Phone application specifically focusing on creating a "Windows Phone HTML 5 app". However, I have encountered an issue while using ajax with Jquery (version 1.9.1). The snippet of my code is as follows: ...

Beginning the phone application using either HTML5 or Cordova

Is there a way to use either HTML5 or Cordova (PhoneGap) to initiate a call to a phone number? I am looking to create a button that says "Call 555-555-5555", and when clicked, it opens the phone app on the device with that specific number. ...

I am attempting to dynamically align the images of two articles. The exact heights of the containers are not specified. Can anyone provide guidance on how to achieve this?

My code snippets: <article class="featured"> <img src="http://www.placehold.it/300x100/ff0000"> <p> <!--Text--> </p> </article> <article class="sub-featured"> <img src="http://www.placeh ...

What steps should I take to ensure that the login page functions properly?

Below is the HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login Pag ...

Angular ng-repeat can sometimes lead to annoying flickering on the webpage

I have a code snippet that displays a list of thumbnails: <div class ="channel" ng-repeat ="channel in UIModel.channels" ng-class ="{evenchannel: ($index % 2) == 0, oddchannel: ($index % 2) == 1}"> <img class="channel-img" ng-src ="da ...

What is the best way to increase the spacing between inline-block elements?

Just to clarify, I am not looking to delete space between inline-block elements - rather, I want to insert it. My goal is to create a grid of menu items that can accommodate 2, 3, or 4 items per row, and I hope to achieve this using media queries. Is the ...

Updating dropdown menu selection after successful form submission validation

I'm currently working on a PHP sign up/registration form that retains and resubmits user input if validation fails. Although I have successfully implemented text boxes, password inputs, and radio buttons, I am encountering some challenges with the dro ...

Show information from the console logger

I'm currently working on displaying data from a database in an HTML page. While the data is showing up in my console, I'm struggling to figure out how to present it in an HTML table format. I'm unsure about the specific function that needs t ...

Here's a quick tip for adding a new line in your input message in Angular - just press Shift +

I need help with my chat box input field. I want it to be able to handle new line inputs similar to Facebook's chatbox. Here is a screenshot of My Chat Box: [1]: https://i.sstatic.net/NeG7d.png My HTML code for the input field: <form class=" ...

Tips for setting up a hierarchical mat-table within a parent table that supports expandable rows using Angular Material

Here is the data that I am working with: [ { "_id": "c9d5ab1a", "subdomain": "wing", "domain": "aircraft", "part_id": "c9d5ab1a", "info.mimetype": "application/json", "info.dependent": "parent", ...

Crafting a template for mixing up images and quotes without any specific connection - here's how!

I came across some interesting templates that can generate random quotes and others that create random pictures. My goal is to develop a template that generates both a random quote and a random picture, similar to this example, without any relation betwee ...

Is there a way to split each foreach value into distinct variables?

I am looking to assign different variables to foreach values. I have fetched data from an API in JSON format, and then echoed those values using a foreach loop. My goal is to display the echoed value in an input box using JavaScript. I attempted the follow ...