Hip
Hip

Reputation: 87

How can I use "text-decoration" within <span> in CSS?

I would like to use text-decoration to underline a word in a heading but I can't figure out how to do it in CSS. Is it even possible? I thought about using <span> but is there a way to use multiple spans and address them separately in CSS?

Upvotes: 1

Views: 2410

Answers (2)

user7896971
user7896971

Reputation:

Since you want to do it using CSS, you can assign an id to the span element. Then use CSS to style it

<span id="under">Hello</span>

And the CSS

#under{
    text-decoration : underline;
}

And if you want to underline multiple spans, you can use class attribute.

<span class="under"> </span>

.under{
text-decoration : underline;
}

Upvotes: 3

Paper
Paper

Reputation: 1313

For underlined text in HTML, use the <u> tag.

Upvotes: 0

Related Questions