--- title: String.prototype.small() slug: Web/JavaScript/Reference/Global_Objects/String/small tags: - Deprecated - HTML wrapper methods - JavaScript - Method - Prototype - Reference - String translation_of: Web/JavaScript/Reference/Global_Objects/String/small ---
small() メソッドは、文字列が小さなフォントで表示されるように HTML の {{HTMLElement("small")}} 要素を生成します。
str.small()
HTML の {{HTMLElement("small")}} 要素を含む文字列です。
small() メソッドは、文字列を <small> 要素の中に、 "<small>str</small>" のように埋め込みます。
以下の例では文字列のメソッドを使用して、文字列の大きさを変更しています。
var worldString = 'Hello, world'; console.log(worldString.small()); // <small>Hello, world</small> console.log(worldString.big()); // <big>Hello, world</big> console.log(worldString.fontsize(7)); // <font size="7">Hello, world</fontsize>
{{domxref("ElementCSSInlineStyle/style", "element.style")}} オブジェクトを使用すると、要素の style 属性を使用して、次のようにもっと汎用的に操作することができます。
document.getElementById('yourElemId').style.fontSize = '0.7em';
| 仕様書 |
|---|
| {{SpecName('ESDraft', '#sec-string.prototype.small', 'String.prototype.small')}} |
{{Compat("javascript.builtins.String.small")}}