简体   繁体   中英

HTML/css text in table cell not indenting

A simple question but large impact on appearance.

I want text indented from cell border and have tried style=text-indent: 4px (not formatted so it displays properly here) but while the first line is indented, the lines after the <br> tags are not indenting. Please help. I need to use div because of some Javascript. Here is flawed code:

<td>
   <div id="navbar" style="text-indent:4px"><b>View by:</b><br>
      <a href="search.php?cat=pop">Popular</a><br>
      <a href="search.php?cat=trend">Trending</a><br>
   </div>
</td>

text-indent is only supposed to touch the first line. Use margin (or margin-left or padding or etc) if you want to adjust the entire block.

尝试向元素添加填充,该元素包含您要缩进的文本。

   <td style="padding:5px;">text</td>

当无法缩进时,我通过添加下面的样式来解决它。

overflow-wrap: break-word;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM