--- 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 ---
{{JSRef}} {{deprecated_header}}

small() メソッドは、文字列が小さなフォントで表示されるように HTML の {{HTMLElement("small")}} 要素を生成します。

構文

small()

返値

HTML の {{HTMLElement("small")}} 要素を含む文字列です。

解説

small() メソッドは、文字列を <small> 要素の中に、 "<small>str</small>" のように埋め込みます。

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';

仕様書

{{Specifications}}

ブラウザーの互換性

{{Compat}}

関連情報