[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize [Back]  [Original]

String.prototype.fontsize() - JavaScript | MDN

Esta pgina ha sido traducida del ingls por la comunidad. Aprende ms y nete a la comunidad de MDN Web Docs.

View in English Always switch to English

String.prototype.fontsize()

Deprecated

Avoid using this feature in new projects. HTML wrapper methods exist only for backwards compatibility. Use DOM APIs to create elements instead. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: DOM.

El mtodo fontsize() crea <font> elemento HTML que muestra una cadena con el tamao especificado.

Nota: El elemento <font> ha sido eliminado HTML5 y no se debe usar. Los desarrolladores web deben usar propiedades CSS.

In this article

Sintaxis

str.fontsize(size)

Parmetros

size

Un entero entre 1 y 7.

Descripcin

Cuando especificas el tamao como entero, estableces el tamao de la fuente. Cuando especificas el tamao como cadena tal como "-2", se ajusta el tamao de la fuente al de la etiqueta <basefont>.

When you specify size as an integer, you set the font size of str to one of the 7 defined sizes. When you specify size as a string such as "-2", you adjust the font size of str relative to the size set in the <basefont> tag.

Ejemlpos

Usos fontsize()

The following example uses string methods to change the size of a string:

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>

With the element.style object you can get the element's style attribute and manipulate it more generically, for example:

js
document.getElementById("yourElemId").style.fontSize = "0.7em";

Especificaciones

Specification
ECMAScript 2027 LanguageSpecification
# sec-string.prototype.fontsize

Compatibilidad con navegadores

See also


Web Proxy Viewer  |  New URL  |  Original Page