40

I'm new to html and I got this piece of code:

@{ 
    ViewBag.Title = "Index";
}

<!DOCTYPE html>

<html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>View1</title>
        <script src="~/Scripts/jquery-1.9.1.min.js"></script>
        <script src="~/Scripts/bootstrap.min.js"></script>
        <link href="~/Content/bootstrap-theme.min.css" rel="stylesheet" />
        <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    </head>
    <body>  
        <table>    
            @foreach (var item in Model.Data)
            { 
                <tr>
                    <td><a href=@Model.DataUrl[item.Key]>@item.Key</a></td>
                    <td>@item.Value</td>
                </tr>                        
            }
        </table>
    </body>
</html>

I want to add a tab or spaces between: <td><a href=@Model.DataUrl[item.Key]>@item.Key</a></td> and <td>@item.Value</td> how do I do that?

I guess adding css is the best way but I don't understand how to use it.

President Camacho
  • 1,700
  • 5
  • 23
  • 42

4 Answers4

22

You can add padding to your td with CSS:

td {
  padding-right: 30px;
}
<table>
  <tr>
    <td><a href="#">Hello</a></td>
    <td>Goodbye</td>
  </tr>
  <tr>
    <td><a href="#">Hola</a></td>
    <td>Adios</td>
  </tr>
</table>

or give them a fixed width:

td {
  min-width: 200px;
}
<table>
  <tr>
    <td><a href="#">Hello</a></td>
    <td>Goodbye</td>
  </tr>
  <tr>
    <td><a href="#">Hola</a></td>
    <td>Adios</td>
  </tr>
</table>
JLRishe
  • 95,368
  • 17
  • 122
  • 158
8
`&nbsp;` is a space
`&#09;` is a tab

Just insert them where you want

For the CSS, you should use the padding property, there are plenty of tutorials on the web, and samples

Gerwin
  • 1,503
  • 5
  • 20
  • 50
Deblaton Jean-Philippe
  • 10,809
  • 2
  • 49
  • 65
2

You mean visual whitespace?

In that case, check this link for:

  • How to add styles for a table
  • The paragraph Table Padding specifically.

Basic CSS isn't that hard.

FDM
  • 598
  • 5
  • 15
2
<table style="border-spacing: 10px;">

Or in a CSS block somewhere:

table {
  border-spacing: 10px;
}

Source : Add space between cells (td) using css

Community
  • 1
  • 1
Djoezz
  • 70
  • 2
  • 9