نمط خاصية whiteSpace
مثال
حدد أن النص الموجود في عنصر <div> لن يلتف أبدًا:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
التعريف والاستخدام
تقوم خاصية whiteSpace بتعيين أو إرجاع كيفية التعامل مع علامات التبويب وفواصل الأسطر والمسافات البيضاء في النص.
دعم المتصفح
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
بناء الجملة
إرجاع خاصية whiteSpace:
object.style.whiteSpace
قم بتعيين خاصية whiteSpace:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
قيم الملكية
Value | Description |
---|---|
normal | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default |
nowrap | Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br> tag is encountered |
pre | Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the <pre> tag in HTML |
pre-line | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks |
pre-wrap | Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
تفاصيل تقنية
القيمة الافتراضية: | عادي |
---|---|
قيمة الإرجاع: | سلسلة ، تمثل كيفية معالجة المسافة البيضاء داخل عنصر |
إصدار CSS | CSS1 |
مزيد من الأمثلة
مثال
قم بإرجاع خاصية وايت سبيس
alert(document.getElementById("myDiv").style.whiteSpace);
الصفحات ذات الصلة
دروس CSS: نص CSS
مرجع CSS: خاصية مساحة بيضاء
❮ نمط الكائن