خاصية محاذاة النص في CSS
مثال
قم بتعيين محاذاة النص لعناصر <div> مختلفة:
div.a {
text-align: center;
}
div.b {
text-align: left;
}
div.c {
text-align: right;
}
div.c {
text-align:
justify;
}
المزيد من الأمثلة "جربها بنفسك" أدناه.
التعريف والاستخدام
text-align
تحدد الخاصية المحاذاة الأفقية للنص في عنصر ما .
القيمة الافتراضية: | يسارًا إذا كان الاتجاه هو ltr ، ويمينًا إذا كان الاتجاه هو rtl |
---|---|
وارث: | نعم |
متحرك: | رقم. اقرأ عن animatable |
الإصدار: | CSS1 |
بناء جملة JavaScript: | الكائن .style.textAlign = "right" |
دعم المتصفح
تحدد الأرقام الواردة في الجدول إصدار المتصفح الأول الذي يدعم الخاصية بالكامل.
Property | |||||
---|---|---|---|---|---|
text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
بنية CSS
text-align: left|right|center|justify|initial|inherit;
قيم الملكية
Value | Description | Play it |
---|---|---|
left | Aligns the text to the left | |
right | Aligns the text to the right | |
center | Centers the text | |
justify | Stretches the lines so that each line has equal width (like in newspapers and magazines) | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
مزيد من الأمثلة
مثال
مثال آخر لمحاذاة النص:
h1 {
text-align: center;
}
p.date {
text-align: right;
}
p.main {
text-align: justify;
}
الصفحات ذات الصلة
دروس CSS: نص CSS
مرجع DOM HTML: خاصية textAlign