शैली फ़ॉन्ट संपत्ति
उदाहरण
किसी तत्व के लिए फ़ॉन्ट सेट करें:
document.getElementById("demo").style.font = "italic bold 20px arial,serif";
परिभाषा और उपयोग
फ़ॉन्ट गुण शॉर्टहैंड रूप में छह अलग-अलग फ़ॉन्ट गुणों को सेट या लौटाता है।
इस संपत्ति के साथ, आप निम्नलिखित (इस क्रम में) को सेट/वापस कर सकते हैं:
- लिपि शैली
- font-संस्करण
- फ़ॉन्ट वजन
- फ़ॉन्ट आकार
- ऊंची लाईन
- फ़ॉन्ट परिवार
फ़ॉन्ट-आकार और फ़ॉन्ट-परिवार आवश्यक हैं। यदि अन्य मानों में से कोई एक गुम है, तो डिफ़ॉल्ट मान सम्मिलित किए जाएंगे, यदि कोई हो।
उपरोक्त गुणों को अलग शैली गुणों के साथ भी सेट किया जा सकता है। बेहतर नियंत्रणीयता के लिए गैर-उन्नत लेखकों के लिए अलग-अलग गुणों के उपयोग की अत्यधिक अनुशंसा की जाती है।
ब्राउज़र समर्थन
Property | |||||
---|---|---|---|---|---|
font | Yes | Yes | Yes | Yes | Yes |
वाक्य - विन्यास
फ़ॉन्ट गुण लौटाएं:
object.style.font
फ़ॉन्ट गुण सेट करें:
object.style.font = "font-style font-variant font-weight font-size/line-height|caption|icon|menu|
message-box|small-caption|status-bar|initial|inherit;"
सम्पत्ति की कीमत
Value | Description |
---|---|
style | Sets the font-style |
variant | Sets the text in a small-caps font |
weight | Sets the boldness of the font |
size | Sets the size of the font |
lineHeight | Sets the distance between lines |
family | Sets the font face |
caption | The font used for captioned controls (like buttons, drop-downs, etc.) |
icon | The font used to label icons |
menu | The font used in menus |
message-box | The font used in dialog boxes |
small-caption | The font used in small controls |
status-bar | The font used in window status bars |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
टेक्निकल डिटेल
डिफ़ॉल्ट मान: | निर्दिष्ट नहीं है |
---|---|
प्रतिलाभ की मात्रा: | एक स्ट्रिंग, तत्व के विभिन्न फ़ॉन्ट गुणों का प्रतिनिधित्व करता है |
सीएसएस संस्करण | सीएसएस 1 |
और ज्यादा उदाहरण
उदाहरण
किसी तत्व का फ़ॉन्ट लौटाएं:
alert(document.getElementById("demo").style.font);
संबंधित पृष्ठ
सीएसएस ट्यूटोरियल: सीएसएस फ़ॉन्ट
सीएसएस संदर्भ: फ़ॉन्ट गुण
❮ स्टाइल ऑब्जेक्ट