How to perfectly align two table headings with the help of HTML and CSS

I am trying to position these 2 table names at the top, so that each table name is centered at the top of the respective table.

https://i.sstatic.net/j6cJG.png

CSS:

     p{
            color: blue;
        }

        table.table1 {
            float: left;
            display: inline-block
            font-size: large;
            border: 1px solid black;
        }

HTML:

        <p>Employee Table</p>
        <!-- TABLE CONSTRUCTION -->
        <table class="table1">

Answer №1

Enhance the layout of your table by enclosing it with some wrappers: https://jsfiddle.net/wf5qargj/

<h1>Main Heading</h1>
<div class="outer">
  <div class="wrapper">
    <h2>Heading T1</h2>
    <table id="t1">
      <tr><td>...<td></tr>
      ....
    </table>
  </div>
  <div class="wrapper">
    <h2>Heading T2</h2>
    <table id="t2">
      <tr><td>...<td></tr>
      ....
    </table>
  </div>
</div>

.outer {
  display: flex;
}
td,th {
  border: 1px solid grey;
}
table {
  width:300px;
}
h2 {
  text-align:center;
}

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

Combining the power of jQuery with the versatility of HTML5's geo location feature,

Recently on the forum, I sought assistance with my geo location manager as I encountered a dilemma. I realized that the geo location is asynchronous, but I prefer it to be synchronous for easier programming. Credit goes to making3 for providing the soluti ...

the recurring pattern of media conditions in every single column

Hello, I'm currently involved in a project where I have implemented media conditions for my columns using Sass. Here is the code snippet: // Mobile media - 320px width @mixin mobile{ @media only screen and (max-width:767px){ width: 300px; } } B ...

Prevent double tap selection

At times, I enable the user to click on the <li> or <span class="icon"> elements, but if they happen to click twice, it causes a bit of chaos and spreads the blue selection all over :/ To address this issue, I have come up with two solutions: ...

range input in firefox not functioning properly with focus method

One issue with using the input type range in HTML code is that when a focus event is triggered, it may not work properly in Firefox. Below is an example of the code: var p = document.getElementById("price"), res = document.getElementById("result"); t ...

Prevent fluctuations in container height + tips for aligning a list item at the bottom

In my jsFiddle demo here, I have implemented a vertical menu. Upon hovering on the icon, I would like the description of that menu to appear with a fade effect. Q1: However, during the fading transition, the text in the description wraps into a new line, ...

Switch between dynamically generated div elements

Currently, I am in the process of developing my own lightweight blogging platform as a way to enhance my skills in PHP and jQuery without depending on Wordpress. The pagination system I have created displays 5 blog posts per page using PHP. However, within ...

Which specific part of this jQuery code is causing issues with compatibility on IE6 and IE7?

This JavaScript function duplicates an element within a form. It performs well across most browsers but encounters issues with Internet Explorer versions 6 and 7. The problem arises from the fact that it fails to increment the name attribute of the duplica ...

Positioning an element absolutely inside a Material-UI React dialog

Currently, I am working on a Dialog component that includes a button located in the bottom right corner. When this button is clicked, it triggers the display of another div containing a list of items. However, I have encountered an issue where the list is ...

What is the best way to eliminate a specific set of characters from a string using TypeScript?

Imagine you have the following lines of code stored in a string variable: let images='<img alt="image1" height="200" src="image1.jpg" width="800"> <img alt="image2" src="image2.jpg" height="501" width="1233"> <img alt="im ...

Ways to make child UL appear outside of parent UL

I understand the behavior issue highlighted in the title, but I am searching for a solution. I have created an example on JSfiddle: http://jsfiddle.net/TBXr4/2/ In the first LI element, there are several words. They are not aligning as I would like them ...

Error with displaying icon font within a box in Internet Explorer

Utilizing Wordpress with the UDesign theme has allowed me to incorporate iconfonts on my website within small blue boxes. You can view these icons in action on this page: To achieve this look, I had to customize the CSS by following an online tutorial tha ...

Using JQuery to iterate through every unique div id in the HTML document

i am attempting to utilize jquery to iterate through each div tag that has an id of "rate". The goal is for jquery to execute a function on the individual divs. Here is my code snippet: information.html <html> <input class="rate" type="hidden ...

What is the method for adjusting the position of this box-shadow?

As a beginner in coding, I stumbled upon this box shadow effect online but I am struggling to adjust it to match the font style I am using. Here is the CSS for the title: .sidebar-title { position:absolute; z-index:150; top:100px; left:330px; ...

Can the viewport width be captured and stored in a MySQL database using jQuery, and subsequently retrieved in PHP without needing to reload the page?

Appreciate you taking the time to go through this... I have a question regarding hidden content with CSS. As far as I know, hidden content still loads but remains hidden. Instead of using media queries to control the visibility of the content based on the ...

Enabling or Disabling CSS Background Clip Support for Internet Explorer

Applying background-clip to text is effective on most browsers, except for IE! .main-menu .nav li a { font-family: freight-big-pro, serif; font-size: 4rem; font-weight: 400; color: #0f0e0e; text-decoration: none; -webkit-background ...

What can I do to ensure that this is responsive across all devices?

Hey there! I need some assistance with making my Chat site/application responsive. I'm not too familiar with CSS, but I'm the sole developer on this project, so I'm trying my best. I initially designed the site in Photoshop and then started ...

Disappear from Sight: Content Concealed as Window Size Changes

Struggling with resizing text and buttons on a website built from a template for class. Looking to ensure that the text remains visible even when the window size changes. Ideally, I want the page content to stay anchored so the focus remains on the text/b ...

Steps to deactivate the select element in backbone.js

Can someone help me with disabling the select option in my MVC template code using backbone.js? I tried using readonly="readonly" and disable="disable", but it sends null as value and doesn't update my address. <div class="login-register" data-val ...

Is it possible to replace a hover dropdown with a click in CSS?

Currently, I have created dropdowns in CSS using the following code: .menu ul ul, .menu .mega-menu, .menu .mega-menu ol li { opacity: 0; visibility: hidden; } .menu li:hover > ul, .menu li:hover > .mega-menu, .menu li:hover > .mega-menu ...

Steps for confirming the chosen selection in a dropdown menu on Internet Explorer

I am encountering a challenge in verifying the selection of an option in a dropdown menu. Within my application, there is a dropdown with 10 different options. When I choose option 5, I need to confirm that it was indeed selected. It's straightforwar ...