Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to make the HTML underline thicker?

I have a centered div with a nested h1 inside. Is there any way to underline it with a thicker line than the html default?

like image 940
Rodrigo Avatar asked Jun 28 '10 17:06

Rodrigo


People also ask

How do you change underline style in HTML?

Change the underline to dots with the border-bottom style property a { text-decoration: none; border-bottom:1px dotted; }. Change the underline color by typing a { text-decoration: none; border-bottom:1px solid red; }.


3 Answers

This will give you control over the U tag's underline:

<style type="text/css">
  u {
    text-decoration: none;
    border-bottom: 4px solid black;
  }
</style>

In this case the underline will be four pixels.

like image 95
Gert Grenander Avatar answered Oct 20 '22 21:10

Gert Grenander


No, there isn’t. The thickness of the underline is browser-dependent and cannot be affected in CSS (or HTML).

There was once a text-underline-width property suggested in the CSS3 Text draft. But there was insufficient interest in it, and it was removed from the draft in 2005. It was probably never implemented.

The usual workaround is to use a bottom border instead of an underline. However, note that it is a different thing. The bottom border is below the line box, whereas an underline is normally on the baseline of text and therefore cuts descenders of letters. Generally, a bottom border is better for legibility than an underline, but it deviates from typographic tradition.

The following example demonstrates the differences.

<span style="text-decoration: underline">jgq</span>
<span style="border-bottom: solid 1px">jgq</span>
<span style="border-bottom: solid 4px">jgq</span>
like image 35
Jukka K. Korpela Avatar answered Oct 20 '22 21:10

Jukka K. Korpela


I am not recommending inline CSS but have used it here for brevity:

<h1 style="border-bottom: 5px solid black">
like image 29
D'Arcy Rittich Avatar answered Oct 20 '22 21:10

D'Arcy Rittich