--- title: String.prototype.small() slug: Web/JavaScript/Reference/Global_Objects/String/small tags: - Deprecated - HTML wrapper methods - JavaScript - Method - Prototype - Reference - String - Polyfill browser-compat: javascript.builtins.String.small translation_of: Web/JavaScript/Reference/Global_Objects/String/small ---
small()
メソッドは、文字列が小さなフォントで表示されるように HTML の {{HTMLElement("small")}} 要素を生成します。
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("HTMLElement/style", "element.style")}} オブジェクトを使用すると、要素の style
属性を使用して、次のようにもっと汎用的に操作することができます。
document.getElementById('yourElemId').style.fontSize = '0.7em';
{{Compat}}
String.prototype.small
のポリフィルは core-js
で利用できます