Or is it used for hyperlinks?
Hyperlinks automatically do that. It’s used to underline text.
I will have to admit this one is a new one for me! (I have been with HTML for years)
So, I did a quick research. It is for neither underlining text or creating hyperlinks. Instead, it is used to represent a misspelled word
For example:
<p>This is a <u>parrapgraph</u></p>
Check out further information here
I came across that information too but I also found pages saying that it was sued for hyperlinks and others saying it underlines text. When I use it inside a piece of text, the words I apply <u>
around become underlined
So, I did some further digging. By the way, I do now remember this <u>
tag (I apologised for my brain to be at the speed of a snail )
Anyway, in the older HTML versions, the purpose of the <u>
tag was to underline the text.
Now, this is no longer the case in HTML 5. The purpose of it has changed. It is now to represent a text with a spelling mistake (as I mentioned above).
However, every element has a default style that is set by the browser. This will be displayed if we (developers) have not applied any styling (via CSS) to it.
For example, the hyperlinks (<a>
tag) we see on the screen will have a blue colour and it is underlined by default if they have not been styled.
This goes the same for the <u>
tag in the current version of HTML5. The purpose is the spelling mistake, but its appearance is underline due to the browser default styling.
Now, I can understand why it is not recommended to use the <u>
tag as it is a rather confusing issue.
I will say that when I learn HTML & CSS for the very first time (this was done in the early 2000s and it was the older HTML versions then), it was always recommended to underline a text via CSS.
Here is a basic example
HTML
<p>This is how it should be <span>underlined</span>!</p>
CSS
span {
text-decoration: underline;
}
I hope this have now answered your question
Yes it has, thank you for your help!
All those come from what’s called the user agent stylesheet.
@martaramos and also, thank you as I have also learn something new too!
Yep! That is exactly it! Even though the word user agent feels very…James Bond