HTML Element: <wbr>
[this page | pdf | back links]
The HTML <wbr> element indicates a possible
line-break (i.e. ‘word break opportunity’). It is new in HTML 5. When a word is
long and the browser might break text lines in wrong places then <wbr> elements offer scope to
add word break opportunities.
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>
Text without a word break opportunity between a's and b's:<br>
<p style="width:100px; border: thin solid black;">aaaaaaaaabbbbbbbbbbbb</p><br><br>
Text with a word break opportunity between a's and b's:<br>
<p style="width:100px; border: thin solid black;">aaaaaaaaa<wbr>bbbbbbbbbbbb</p>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("P");
x.setAttribute("style","width:100px; border: thin solid black;")
var txt1 = document.createTextNode("aaaaaaaaa"); x.appendChild(txt1);
var y = document.createElement("WBR");
x.appendChild(y);
var txt2 = document.createTextNode("bbbbbbbbbbbb"); x.appendChild(txt2);
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements