Arranging the <td> element with inline styles (email)

I am trying to format an email signature using a table, but I am facing an issue with how it appears on mobile devices.

On mobile screens, the text gets compressed and I want the second image to be displayed below the first one along with the text. While flex-wrap would solve this issue using Flexbox, I am hesitant to use it as it may not be supported in emails.

The HTML structure of my signature is as follows:

<!DOCTYPE html>
<html lang="cs">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    </head>
    <body>
        <table
            style="
                font-family: Calibri, 'Trebuchet MS', sans-serif;
                border-color: transparent;
                border-collapse: collapse;
                table-layout: fixed;
                overflow-wrap: normal;
            "
        >
            <tr>
                <td
                    rowspan="6"
                    style="
                        padding-right: 10px;
                        vertical-align: middle;
                        width: 130px;
                    "
                >
                    <img
                        src="https://via.placeholder.com/130"
                        alt=""
                        width="130"
                        height="130"
                    />
                </td>
                <td>
                    <span style="color: #237; font-weight: 600; font-size: 20px"
                        >Ing. Jan Novák</span
                    >
                </td>
                <td
                    rowspan="6"
                    style="
                        padding-left: 30px;
                        vertical-align: middle;
                        width: 130px;
                    "
                >
                    <img
                        src="https://via.placeholder.com/130"
                        alt=""
                        width="130"
                        height="130"
                    />
                </td>
            </tr>
            <tr>
                <td>
                    <span style="color: #5d6d7f">ředitel FOOBAR a.s.</span>
                </td>
            </tr>
            <tr>
                <td>
                    <table
                        style="
                            border: none;
                            border-color: transparent;
                            border-collapse: collapse;
                            table-layout: fixed;
                        "
                    >
                        <tr>
                            <td>
                                <span style="color: #5d6d7f">Mobil: </span>
                            </td>
                            <td>
                                <a
                                    href="tel:+420123456789"
                                    style="
                                        color: #237;
                                        text-decoration: none;
                                        font-weight: 600;
                                    "
                                    >+420 123 456 789</a
                                >
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="color: #5d6d7f">E-mail: </span>
                            </td>
                            <td>
                                <a
                                    href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="caa4a5bcaba18aaca5a5a8abb8e4a9a5a7">[email protected]</a>"
                                    style="color: #237; text-decoration: none"
                                    ><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="16787960777d567079797477643875797b">[email protected]</a></a
                                >
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="color: #5d6d7f">Web: </span>
                            </td>
                            <td>
                                <a
                                    href="https://foobar.com"
                                    style="color: #237; text-decoration: none"
                                    >foobar.com</a
                                >
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <a
                        href="https://via.placeholder.com/150"
                        download
                        style="color: #5d6d7f; font-size: 12px"
                        >Vizitka ke stažení</a
                    >
                </td>
            </tr>
        </table>
    </body>
</html>

If you have any suggestions or solutions, your help would be greatly appreciated. Thank you in advance!

Answer №1

Need a solution that's not entirely complete? Here's a helpful guide to point you in the right direction. For a better view of how your design changes on different screen sizes, switch the snippet result to "full page" mode for a desktop version display rather than just a small preview.

I made use of media queries to toggle between views at 800px width, but feel free to adjust this according to your needs.

The key adjustment I made was hiding and revealing the third cell along with another row (which is actually the fifth row) containing one cell that mirrors the content of the third cell/column in desktop layout. I achieved this by duplicating the code within that td into a newly created additional tr and assigning classes to both elements, which are styled via CSS.

Quick note: The first and third cells should have rowspan="4" instead of 6 to account for a nested table in the third row of the second column, counting as one row for the first and third rows.

Hopefully, the explanation above clarifies things ;-)

.x {
  display: table-cell;
}

.y {
  display: none;
}

@media screen and (max-width: 800px) {
  .x {
    display: none;
  }
  .y {
    display: table-row;
  }
  .y > td {
    padding-left: 0 !important;
  }
}
<!DOCTYPE html>
<html lang="cs">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>

<body>
  <table style="
                font-family: Calibri, 'Trebuchet MS', sans-serif;
                border-color: transparent;
                border-collapse: collapse;
                table-layout: fixed;
                overflow-wrap: normal;
            ">
    <tr>
      <td rowspan="4" style="
                        padding-right: 10px;
                        vertical-align: top;
                        width: 130px;
                    ">
        <img src="https://via.placeholder.com/130" alt="" width="130" height="130" />
      </td>
      <td>
        <span style="color: #237; font-weight: 600; font-size: 20px">Ing. Jan Novák</span
                    >
                </td>
                <td class="x"
                    rowspan="4"
                    style="
                        padding-left: 30px;
                        vertical-align: top;
                        width: 130px;
                    "
                >
                    <img
                        src="https://via.placeholder.com/130"
                        alt=""
                        width="130"
                        height="130"
                    />
                </td>
            </tr>
            <tr>
                <td>
                    <span style="color: #5d6d7f">ředitel FOOBAR a.s.</span>
      </td>
    </tr>
    <tr>
      <td>
        <table style="
                            border: none;
                            border-color: transparent;
                            border-collapse: collapse;
                            table-layout: fixed;
                        ">
          <tr>
            <td>
              <span style="color: #5d6d7f">Mobil: </span>
            </td>
            <td>
              <a href="tel:+420123456789" style="
                                        color: #237;
                                        text-decoration: none;
                                        font-weight: 600;
                                    ">+420 123 456 789</a
                                >
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="color: #5d6d7f">E-mail: </span>
                            </td>
                            <td>
                                <a
                                    href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1876776e7973587e77777a796a367b7775">[email protected]</a>"
                                    style="color: #237; text-decoration: none"
                                    ><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a44455c4b416a4c4545484b5804494547">[email protected]</a></a
                                >
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="color: #5d6d7f">Web: </span>
                            </td>
                            <td>
                                <a
                                    href="https://foobar.com"
                                    style="color: #237; text-decoration: none"
                                    >foobar.com</a
                                >
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <a
                        href="https://via.placeholder.com/150"
                        download
                        style="color: #5d6d7f; font-size: 12px"
                        >Vizitka ke stažení</a
                    >
                </td>
            </tr>
            <tr class="y">
             <td 
                    colspan="2"
                    rowspan="4"
                    style="
                        padding-left: 30px;
                        vertical-align: middle;
                        width: 130px;
                    "
                >
                    <img
                        src="https://via.placeholder.com/130"
                        alt=""
                        width="130"
                        height="130"
                    />
                </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

Avoid duplication of choices on two checkboxes containing the same options

I have two select boxes where I am trying to prevent duplicated values (options) in each select box. Both select boxes start with the same options list, but once an option is selected in selectA, it should no longer be visible in selectB, and vice versa. T ...

The paragraph text should dynamically update upon clicking a button based on JavaScript code, however, the text remains unchanged despite attempts to modify it

I recently started learning JavaScript and wanted to update the content of a paragraph when a button is clicked. However, I encountered an issue where this functionality doesn't seem to work. <body> <p id="paragraph">Change Text on cl ...

A guide on extracting a div element without a class using Html Agility Pack

Can you help me extract the text 'Galatasaray.' from the HTML code below? I'm not sure how to specify it properly. <div class="dRib1"> <h2>Information</h2> </div> <div>Galatasaray.</div> ...

How do I handle a Flask request from an HTML form that is returning a None value?

I am unable to retrieve the value on request in my Flask application. Instead of the expected value, it is returning None. Despite trying to change the method, I am still facing this issue. Here is the Flask code snippet: @app.route("/login/user/book") ...

Tips for effectively showcasing dynamic data retrieved from a database

I need to showcase my dynamic data from a database in a specific format that can accommodate anywhere from one to five variables. https://i.sstatic.net/pPQZE.png https://i.sstatic.net/gSJw6.png How can I effectively display and present the data using HTML ...

The HTML5 onclick function is not functioning properly on the button

My HTML file includes a button with the id "botonRegistro" that should call a function when clicked. However, nothing happens and no alerts are displayed. I'm not sure why this button is not working while other buttons do. <!DOCTYPE html> <h ...

Use JavaScript to change the text of a hyperlink to @sometext

<li class="some-class one-more"><label>twitter:</label> <a href="https://twitter.com/sometext?s=09" target="_blank" rel="noreferrer noopener">https://twitter.com/sometext?s=09</a> < ...

Extract content from a label with jQuery

Snippet var $eContainer = $('<div/>', { id: "eContainer", class: 'eList' }).appendTo($injectTo); for (var i in navProps) { var np = navProps[i]; var npName = np.name; var npId = containerId + "_" + npN ...

The function I created is having trouble connecting to the controller.js file

My JavaScript controller file function ServicesCtrl($scope) { console.log("Greetings from ServicesCtrl"); $scope.message = "Hello!"; } The main HTML file <html> <head> <title>The Complete Web Development Stack</ti ...

Defense Against Altering POST Values via Browser Developer Tools

   Having searched extensively, I have been unable to locate an answer to my question...or perhaps I am not phrasing it correctly in my searches. Anyways, below is my question and description: As I develop a web application using Django, Javascript, H ...

Website glitch encountered on Flash when using Firefox and IE9, though surprisingly functions perfectly on IE6!

My website isn't functioning properly on Firefox versions 4 and 7. Nothing is appearing, not even the alternative content. In IE9, the issue is that the content is condensed at the top of the page... although it works fine on IE6! Here is the HTML c ...

Is it possible to separate the words in my navigation bar to create more spacing and change the color of the text to white?

I've been attempting to create a navigation bar without much success. My goal is to position the words "Main Page", "About Me", and "Bibliography" with space between them, aligned left, center, and right respectively. Additionally, I want to change t ...

What is the best way to create a full bleed background image that adjusts to different screen resolutions using CSS and JavaScript?

Similar Question: Full Screen Background Image in Firefox Check out: Is there a way to achieve a similar effect on a website where the content adjusts to different monitor resolutions? On the Ingress site, it seems like everything scales proportional ...

instructions for ensuring gridview spans entire width of panel

I have a gridview that is contained within a panel. I am trying to make the gridview fill 100% of the width and height of the panel. This is what I've attempted so far: CSS .pnlGridView { position:relative; float:right; heig ...

Ways to execute a function when a button is clicked with a shared variable?

When creating buttons in HTML to control video speed, I encountered a strange issue. After successfully implementing the buttons for one video, they only worked on a second video and had no impact on the first one. Deleting the second video seemed to resol ...

What is causing my `<nav>` buttons to be left-aligned?

The attempt to center the buttons in the viewport using text-align:center for nav, ul, and li has proved ineffective. The alternative of nav {text-align: left;} was no more successful. CSS Snippets: #container { width: 100%; background-color: bla ...

CSS Safari link not aligned properly

My issue involves Safari. When viewed in other browsers, the input and link on the second row appear on the same line, but Safari displays them differently. Any thoughts on why this might be happening? HTML <div id="searchWrapper01"> <d ...

Find out the index of a div within an array

Curious about determining the position of a div in an argument? For instance, if there are multiple divs with the same name: <div class="woot"></div> <div class="woot"></div> <div class="woot"></div> <div class="woot ...

What is the most efficient way to print multiple JSON arrays simultaneously?

When looping through a database using an array, the following code snippet is used: $checkedProducts = $request->input('products'); $p = null; foreach($checkedProducts as $checkedProduct){ $p .= DB::table('products')->where( ...

What is the relationship between html, body, and window when scrolling through code?

I've been working on adding a scroll-to-top button to my website. After doing some research online, I came across this code snippet: $('html, body').animate({scrollTop:0}, 'slow'); It's interesting that they are trying to scr ...