Search code examples
htmlcssalignment

HTML/PHP - Align text on character


I've got a webpage which prints strings from an SQLITE database. There are two values, questions and answers. What I'm trying to do is align the strings on the seperator '='.

What currently comes out:

a = b
hello = Hello.
bey = Bye.

What I want:

a     = b
hello = Hello.
bye   = Bye.

Is this possible within PHP/HTML? If so, how would I go on about doing that? Your answers are really appreciated!


Solution

  • Here it is:

    <!DOCTYPE html>
    <html>
    
      <head>
        <title>HTML Tables</title>
      </head>
    
      <body>
        <table border="0">
          <tr>
            <td>a </td>
            <td>= </td>
            <td>b</td>
          </tr>
          <tr>
            <td>hello </td>
            <td>=</td>
            <td>Hello</td>
          </tr>
          <tr>
            <td>bye </td>
            <td>=</td>
            <td>Bye.</td>
          </tr>
        </table>
      </body>
    
    </html>
    

    Demo:

    https://jsfiddle.net/ismaakeel/9ujawg2u/4/