45

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,860
  • 6
  • 27
  • 44

4 Answers4

23

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
  • 99,490
  • 19
  • 131
  • 169
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,572
  • 5
  • 23
  • 51
Deblaton Jean-Philippe
  • 11,188
  • 3
  • 49
  • 66
3
<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
  • 80
  • 1
  • 9
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
  • 628
  • 6
  • 18