0

I can't figure out how to have the text display on a single line instead of on multiple lines.

This what the user sees

When I list my choices, some fields take up three lines, which makes the list difficult to read.

<td width="205px" height="15px" TextMode="SingleLine">
    @item.Adresse
</td>

I want all of the lines to be a single line in height.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Peter
  • 148
  • 1
  • 2
  • 18
  • 1
    have you tried to set `style="white-space:nowrap;"`? – aamd Aug 16 '21 at 18:25
  • Well that was an easy one. Worked great. – Peter Aug 16 '21 at 18:31
  • As an aside, the `TextMode` attribute is part of ASP.NET Web Forms, but you tagged this question with ASP.NET Core, and the `@item.Adresse` is part of the Razor syntax. These are not intercompatible. If you're using ASP.NET Core with Razor templates, you cannot use ASP.NET Web Forms attributes. (Though, even if you were using Web Forms, you'd have still required a `runat="Server"`.) – Jeremy Caney Aug 16 '21 at 19:13

1 Answers1

1

There are two ways:

  1. Via the white-space CSS property, e.g.:

    <td style="white-space: nowrap" />
    

    or

  2. nowrap attribute on the td HTML element, e.g.:

    <td nowrap />
    
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Dom
  • 11
  • 1
  • I've updated your answer so that your markup is visible. By default, HTML elements are assumed to be for formatting, and not displayed a literal text. You can use markdown, however, to not only display them as code blocks, but also to add syntax highlighting, as I've done. Please review the edits so you know how to make similar updates in the future. – Jeremy Caney Aug 16 '21 at 19:06