www.webdeveloper.com
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2010
    Posts
    48

    resolved [RESOLVED] Force td to break before display

    Hi, this is a personal project but I have a thing about being semantically correct about any project I make.

    What I'm trying to achieve is to turn something like this:
    Code:
    <table>
      <tr>
        <th>Name</th>
        <td>Phone</td>
        <td>Address</td>
      </tr>
      <tr>
        <th>Name</th>
        <td>Phone</td>
        <td>E-mail</td>
      </tr>
      <tr>
        <th>Name</th>
        <td>E-mail</td>
      </tr>
    </table>
    into something like this:
    Code:
    * Name
      Phone
      Address
    * Name
      Phone
      E-mail
    * Name
      E-mail
    but I'm getting something this:
    Code:
    * Name
      Phone      Address
    * Name
      Phone      E-mail
    * Name
      E-mail
    with css like this:
    Code:
    html, html * { display: block }
    tr { display: list-item }
    I'll use classes later but for now I'd like to know if anyone can provide a solution.

  2. #2
    Join Date
    Aug 2010
    Posts
    48
    Oh and before anyone says it, yes I know I could've used ul and li but this was a deliberate design choice. The reason: I want the flexibility to switch between tabular and listed format whenever I please whilst maintaining a code format a screen reader or something could convert to something a blind person can read - I use these personal projects as references when I write projects that the public can download.

  3. #3
    Join Date
    Oct 2009
    Posts
    658
    Is the one you're trying to achieve?

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    	<style type="text/css" rel="stylesheet">
    		html, html table tbody tr { display: list-item; }
    		html, html table tbody tr td { display: table-row-group; }
    	</style>
    </head>
    <body>
    <table>
    	<tbody>
      <tr>
        <th>Name</th>
        <td>Phone</td>
        <td>Address</td>
      </tr>
      <tr>
        <th>Name</th>
        <td>Phone</td>
        <td>E-mail</td>
      </tr>
      <tr>
        <th>Name</th>
        <td>E-mail</td>
      </tr>
      </tbody>
    </table>
    </body>
    </html>
    Good Luck

    Santos Systems

  4. #4
    Join Date
    Aug 2010
    Posts
    48
    Thank you, that did the job nicely.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



Recent Articles