Making a nested table inside of another table

I'm working on displaying a block of text within a dynamically generated table (the main table). The main table contains spans that serve as spacers. The issue I'm facing is when the text wraps to the next line, it starts at the beginning of the page instead of continuing from where it left off in the previous line.

Unfortunately, I don't have control over the spans since they are dynamically created, so I can't apply additional styles to them. My workaround involves adding an inner table inside one of the cells of the main table and aligning it inline with the span spacers.

The code snippet below initiates the table on the second line, beneath the span spacers, despite setting the display style property to 'inline-table'.

<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8>
  <title>Document</title>
</head>

<body>
  <table style="width:500px;">
    <tr>
      <td><span style="padding:50px"></span><span style="padding:50px"></span>
        <table style="display:inline-table; vertical-align:top">
          <tr>
            <td>
              HERE IS MY SENTENCE HERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE IS MY SENTENCEHERE
              IS MY SENTENCE.
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>

</html>

The desired output should resemble this:

                             HERE IS MY SENTENCE HERE IS MY 
                             SENTENCEHERE IS MY SENTENCEHERE IS MY 
                             SENTENCEHERE IS MY SENTENCEHERE IS MY 
                             SENTENCEHERE IS MY SENTENCEHERE IS MY 
                             SENTENCEHERE IS MY SENTENCEHERE IS MY 
                             SENTENCEHERE IS MY SENTENCEHERE IS MY 
                             SENTENCEHERE IS MY SENTENCEHERE IS MY 
                             SENTENCE.

Answer №1

Give this code snippet a try. I have also cleaned up the inline styling for you.

 table {
        width: 300px;
        margin-left: auto;
        margin-right: auto;
    }

OR

 table {
        width: 50%;
        margin-left: auto;
        margin-right: auto;
    }

table {
  width: 300px;
  margin-left: auto;
  margin-right: auto;
}
<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8>
  <title>Document</title>
</head>

<body>
  <table>
    <tr>
      <td><span style="padding:50px"></span><span style="padding:50px"></span>
        <table>
          <tr>
            <td>
              HERE IS MY UNIQUE SENTENCE THAT STANDS OUT FROM THE REST.
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>

</html>

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

Detecting iOS format in HTML email communications allows for a more seamless

Recently, I discovered a meta tag that removes the phone number as a link in HTML on iOS. I'm curious if this also works with HTML emails. <meta name="format-detection" content="telephone=no"> I've been using workarounds to handle address ...

Menu selection without javascript

Recently, I encountered an issue with a menu containing tabs. When hovering over a tab, a list of items appears at the bottom of the tab. However, I decided that I wanted this list to transition downwards instead of simply appearing (previously set as disp ...

Retrieving Hyperlinks from JavaScript Object for Integration with D3-Created Table

Issue: I'm facing a problem where the HTML link extracted from an Associative Array is treated as a string instead of being applied as a clickable link in the browser. For a detailed visual example and code snippet, visit: http://example.com/code Da ...

jQuery Mobile Dialog Alert Box

Here's a code snippet that can be used to open a dialog box: <p><a href="ShopItems/Rotax125MicroMax.html" data-rel="dialog" data-role="button">Rotax 125 Micro Max</a></p> Next, we have a page whic ...

Issues with rendering images in the browser due to CSS inline-block layout are causing

I have encountered an issue with two divs that are set to 50% width and displayed inline-block. Each div contains an image. I expected both divs to stay on the same line, but sometimes the browser breaks the layout. Here is the HTML code snippet: <div ...

Optimizing Div Heights with jQuery Scroll

As I scroll down, I want the height of a specific div to decrease instead of the window itself scrolling. The code snippet below illustrates the simple div header setup that I am using: <html> <head> <title>Test</title> ...

Adapting the top margin dynamically for different screen sizes

I am attempting to style an HTML DIV so that the margin-top is adjusted responsively based on the height of the div: jsfiddle Within the wrapper, there is another div that is initially set to display: none, but this may change if the user enters an incorr ...

When a user clicks on an anchor tag, close the current window, open a new window, and pass the

I have a scenario where I have an anchor tag that triggers the opening of a window on click. In this newly opened window, there is a table with a column containing another anchor tag. Here is what I am trying to achieve: Code for the anchor tag: functio ...

Reveal unseen information on the webpage upon clicking a link

I have successfully implemented a fixed header and footer on my webpage. The goal is to make it so that when a user clicks on a link in either the header or footer, the content of that page should appear dynamically. While I have explored various styles, ...

Utilizing HTML and JavaScript to Download Images from a Web Browser

I'm interested in adding a feature that allows users to save an image (svg) from a webpage onto their local machine, but I'm not sure how to go about doing this. I know it can be done with canvas, but I'm unsure about regular images. Here i ...

Steps for serializing multiple sortable items and subitems using jQuery

I found a solution on Stack Overflow that allows me to sort items and subitems using jQuery UI sortable. Everything is sorting correctly, but I'm struggling with serializing the data so that I can update the database accordingly. You can view my curr ...

Troubleshooting the Next.js OG image meta tag issue

<meta property="og:image" content="https://mywebsite.com/images/s1.jpg" After utilizing next/head and inserting the meta tag image above, I encountered an issue where the image did not display when the link was shared. Any suggestio ...

The alignment of the content within a div is mismatched compared to a div that doesn't have any

Can you figure out why the element with content is out of order compared to the other elements without content in the code below? This issue seems to disappear when all elements have content. Any insights on this peculiar behavior? (Thank you in advance fo ...

Deactivate a chosen item following selection

Is there a way to deactivate a selectable element after it has been clicked in the scenario below? Additionally, I would like to modify its CSS style. $(function(){ $("#selectable").selectable({ stop: function() { var result = $( "#select-re ...

Commence the 10-second Redirect Timer

I implemented a page that automatically redirects the user after 10 seconds using the following code snippet. <META HTTP-EQUIV="refresh" CONTENT="10;URL=login.php"> Now, I have this PHP code that I want to display dynamically counting down from 10 ...

Convert an HTML table into an Excel file using PHP

After successfully generating DATA from PHP into an HTML table format, I utilized the code below to export it to EXCEL: header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="BASIC_Data.xls"&apos ...

What is the best way to incorporate a splatter image within an MDX blog post?

I am working on an MDX blog where I render a blog post. pages/index.tsx <main className="flex min-h-screen dark:bg-black"> <div className="wrapper mb-24 gap-8 px-8 lg:grid lg:grid-cols-[1fr,70px,min(70ch,calc(100%-64 ...

Flashing Effect of Angular Ui-Bootstrap Collapse During Page Initialization

Below is the code snippet I've implemented to use the ui-bootstrap collapse directive in my Angular application. HTML: <div ng-controller="frequencyCtrl" style="margin-top:10px"> <button class="btn btn-default" ng-click="isCollapsed = ...

The PhoneGap Android whitelist feature seems to be malfunctioning and preventing navigation to the next page

Currently, I am utilizing the jQuery function load() with the code snippet $('#result').load('http://.... #div'); to retrieve the content of an external website. Moreover, I have made modifications to the domain whitelist specifically f ...

Save and showcase SQL, PHP, HTML, and JS code exactly as it is preserved in MYSQL database

Is there a way to store and display complete JS, PHP, and HTML code in MySQL without altering the format? The stored PHP code should appear as: <?php echo "something"; ?> And not just: something For JavaScript: <script> document.write(&ap ...