blob: cb687b4309c8e63948a9082bf568388c17669d2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
---
title: String.prototype.fontsize()
slug: Web/JavaScript/Reference/Global_Objects/String/fontsize
translation_of: Web/JavaScript/Reference/Global_Objects/String/fontsize
original_slug: Web/JavaScript/Referencia/Objetos_globales/String/fontsize
---
<div>{{JSRef}} {{deprecated_header}}</div>
<p><code>El método </code><strong><code>fontsize()</code></strong> crea {{HTMLElement("font")}} elemento HTML que muestra una cadena con el tamaño especificado.</p>
<div class="note">
<p><strong>Usage note:</strong> El elemento <font> ha sido eliminado <a href="/en-US/docs/Web/Guide/HTML/HTML5">HTML5</a> y no se debe usar. Los desarrolladores web deben usar propiedades <a href="/en-US/docs/Web/CSS">CSS</a>.</p>
</div>
<h2 id="Sintaxis">Sintaxis</h2>
<pre class="syntaxbox"><code><var>str</var>.fontsize(<var>size</var>)</code></pre>
<h3 id="Parámetros">Parámetros</h3>
<dl>
<dt><code>size</code></dt>
<dd>Un entero entre 1 y 7.</dd>
</dl>
<h2 id="Descripción">Descripción</h2>
<p>Cuando especificas el tamaño como entero, estableces el tamaño de la fuente. Cuando especificas el tamaño como cadena tal como "-2", se ajusta el tamaño de la fuente al de la etiqueta {{HTMLElement("basefont")}}.</p>
<p>When you specify size as an integer, you set the font size of <code>str</code> to one of the 7 defined sizes. When you specify <code>size</code> as a string such as "-2", you adjust the font size of <code>str</code> relative to the size set in the {{HTMLElement("basefont")}} tag.</p>
<h2 id="Ejemlpos">Ejemlpos</h2>
<h3 id="Usos_fontsize()"><code>Usos fontsize()</code></h3>
<p>The following example uses string methods to change the size of a string:</p>
<pre class="brush: js">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>
</pre>
<p>With the {{domxref("HTMLElement.style", "element.style")}} object you can get the element's <code>style</code> attribute and manipulate it more generically, for example:</p>
<pre class="brush: js">document.getElementById('yourElemId').style.fontSize = '0.7em';
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('ES6', '#sec-string.prototype.fontsize', 'String.prototype.fontsize')}}</td>
<td>{{Spec2('ES6')}}</td>
<td>Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
{{Compat("javascript.builtins.String.fontsize")}}
<h2 id="See_also">See also</h2>
<ul>
<li>{{jsxref("String.prototype.big()")}}</li>
<li>{{jsxref("String.prototype.small()")}}</li>
</ul>
|