Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3229934
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:52:05+00:00 2026-05-17T16:52:05+00:00

I am coding a java class that generates HTML table reports for JUnit tests

  • 0

I am coding a java class that generates HTML table reports for JUnit tests and use CSS for visual formatting. I am having an issue aligning the cells since the number of colummns generated is unforseeable since some of these columns represent parameters passed into a variadic function. Therefore there is inherent misalignment in the columns. Is there any way to align these cells through a CSS attribute or something? I dont really want to alter the underlying java code to change this aesthetic issue.

Here is what a sample table generated would look like:

http://lh5.ggpht.com/_N67DMbmmQMQ/TK6Q-Vlhd3I/AAAAAAAAAB8/JDFR1B5HX-k/JUnitReportExample.png

Here is the HTML source for the table (formatted properly):

 <html>
    <head>
        <style type="text/css">
            td 
            {
                font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
                font-size: 1em;
                border: 1px solid black;
                padding: 3px 7px 2px 7px;
            }
        </style>
    </head>
    <body>
        <table>
            <tr>
                <td>
                    <b>Method:</b>
                    <font color="blue" face="Verdana">
                        testOne
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        1
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        1
                    </font>
                </td>
                <td>
                    <b>Result:</b>
                    <font color="green" face="Verdana">
                        Passed
                    </font>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Method:</b>
                    <font color="blue" face="Verdana">
                        testTwo
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        BMW
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Audi
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Mercedes
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Porsche
                    </font>
                </td>
                <td>
                    <b>Result:</b>
                    <font color="green" face="Verdana">
                        Passed
                    </font>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Method:</b>
                    <font color="blue" face="Verdana">
                        testThree
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        21154423
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        2443
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        12121
                    </font>
                </td>
                <td>
                    <b>Result:</b>
                    <font color="green" face="Verdana">
                        Passed
                    </font>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Method:</b>
                    <font color="blue" face="Verdana">
                        testFour
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        4.1222
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        2.0001
                    </font>
                </td>
                <td>
                    <b>Result:</b>
                    <font color="red" face="Verdana">
                    Failed
                </td>
            </tr>
            <tr>
                <td>
                    <b>Method:</b>
                    <font color="blue" face="Verdana">
                        testFive
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        10
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        10
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Kungsholmens Hamn
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Melissa Horn
                    </font>
                </td>
                <td>
                    <b>Result:</b>
                    <font color="green" face="Verdana">
                        Passed
                    </font>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Method:</b>
                    <font color="blue" face="Verdana">
                        testSix
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Sweden
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Sweden
                    </font>
                </td>
                <td>
                    <b>Result:</b>
                    <font color="green" face="Verdana">
                        Passed
                    </font>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Method:</b>
                    <font color="blue" face="Verdana">
                        testSeven
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Lisa Ekdahl
                    </font>
                </td>
                <td>
                    <b></b>
                    <font color="purple" face="Verdana">
                        Lisa Ekdahl
                    </font>
                </td>
                <td>
                    <b>Result:</b>
                    <font color="green" face="Verdana">
                        Passed
                    </font>
                </td>
            </tr>
        </table>
    </body>
</html>
</table>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:52:06+00:00Added an answer on May 17, 2026 at 4:52 pm

    I don’t think you will be able to that with simple CSS.

    You don’t want to change your java code for an aesthetic issue but, the problem is that your table really shouldn’t have a changing number of columns. The parameters columns should be only one column with some other means to separate the values. You could generate a comma separated list of the parameters in the second column. That way you would always have 3 columns and the thing will be far easier to format properly.

    If you really want to keep the values in separate columns, you should use the colspan attribute on the last parameter. For example the last parameter column could look like this, with in your java string (or whatever you use to generate the html) looking somewhat like :

    "<td colspan="+ (maxNumberOfColumns-currentColumnIndex) +">"
    

    I strongly suggest you adjust you java code to do this, as the alternatives (modifying with javascript) are a lot more painful (even with things like JQuery).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Java 1.4.2 with unlimited jurisdiction policy files installed. I have a class that
I use JAXB 2.1 to generate Java classes from several XSD files that I
I'm doing some coding in JSP/Java (without any framework, or other strange things) and
I'm looking for a Java profiler that works well with the JVM coming with
I have Java experience and recently am doing some C++ coding. My question is
This my second time coding Java and never referencing any external library before. I
I am coming from Java and am currently working on a C# project. What
When I was learning Java coming from a background of some 20 years of
I'm starting with Python coming from java. I was wondering if there exists something
Coming from a java background, one of the things I am used to is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.