/

HTML / CSS / JavaScript Tutorial

HTML Element: <u>

[this page | pdf | back links]

The HTML <u> element indicates text that should be stylistically different from normal text. It is commonly used for underlining, even though the HTML 5 specification reminds developers that there are almost always other more appropriate ways of achieving a similar effect.

 

The attributes it can take are HTML global attributes and HTML event attributes.

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods. The default style applicable to this element is shown here.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<u>underlined text</u>

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.createElement("U");
x.textContent = "underlined text";
// or use var txt = document.createTextNode("underlined text");
// x.appendChild(txt);
document.getElementById("element").appendChild(x);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile