CSS Property: text-overflow
[this page | pdf | back links]
The CSS (CSS3) text-overflow property indicates how
text that has overflowed is rendered by the browser.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
clip
|
(default value). Text
is clipped without further action
|
ellipsis
|
Clipped text is
rendered by an ellipsis, i.e. “…”
|
string
|
Clipped text is
rendered by the given string
|
Default Value:
|
clip
|
JavaScript syntax:
|
e.g. object.style.textOverflow="ellipsis"
|
Inherited:
|
No
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 80px; border: 2px solid red; white-space: nowrap;
overflow: hidden;}
.x1 {text-overflow: ellipsis}
</style>
</head>
<body>
Not: not all browsers support this style<br>
1. Element with default property<br>
<div>abcd efgh ijkl</div><br><br>
2. Element set using in-file HTML style<br>
<div class="x1">abcd efgh ijkl</div><br>
3. Element set using JavaScript<br>
<div id="x2">abcd efgh ijkl</div>
<script>
document.getElementById("x2").style.textOverflow = "ellipsis";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyTextOverflow() {
var x = document.createElement("DIV"); x.style.textOverflow = "ellipsis"; return (window.getComputedStyle(x, null).textOverflow == "ellipsis");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties