111

How do you underline html text so that the line beneath the text is dotted rather than the standard underline? Preferably, I would like to do this without using a separate CSS file. I'm a novice at html.

4

11 に答える 11

147

CSSがないと無理です。実際、<u>タグはtext-decoration:underlineブラウザの組み込み CSS を使用してテキストに追加するだけです。

できることは次のとおりです。

<html>
<head>
<!-- Other head stuff here, like title or meta -->

<style type="text/css">
u {    
    border-bottom: 1px dotted #000;
    text-decoration: none;
}
</style>
</head>
<!-- Body, content here -->
</html>
于 2013-03-06T16:24:46.457 に答える
68

次の CSS コードを使用してください...

text-decoration:underline;
text-decoration-style: dotted;
于 2016-07-13T07:53:07.500 に答える
16

CSSがないと、基本的に画像タグの使用に固執します。基本的にテキストの画像を作成し、下線を追加します。つまり、基本的に、ページはスクリーンリーダーには役に立たないということです。

CSSを使えば簡単です。

HTML:

<u class="dotted">I like cheese</u>

CSS:

u.dotted{
  border-bottom: 1px dashed #999;
  text-decoration: none; 
}

実行例

サンプルページ

<!DOCTYPE HTML>
<html>
<head>
    <style>
        u.dotted{
          border-bottom: 1px dashed #999;
          text-decoration: none; 
        }
    </style>
</head>
<body>
    <u class="dotted">I like cheese</u>
</body>
</html>
于 2013-03-06T16:25:55.563 に答える
14

HTML5 要素は点線の下線を付けることができるため、下のテキストには通常の下線ではなく点線が表示されます。また、 title 属性は、ユーザーが要素の上にカーソルを置いたときにツール ヒントを作成します。

注: Firefox と Opera ではデフォルトで点線/下線が表示されますが、IE8、Safari、および Chrome では CSS の行が必要です。

<abbr title="Hyper Text Markup Language">HTML</abbr>
于 2016-07-11T14:14:27.207 に答える
1

プロパティを利用できtext-decorationます:

    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
于 2021-10-02T01:23:33.290 に答える
-2

CSSなしでは不可能ではありません。たとえば、リスト項目として:

<li style="border-bottom: 1px dashed"><!--content --></li>
于 2015-04-30T09:03:55.750 に答える