Propriedade fontSize do estilo
Exemplo
Defina o tamanho da fonte de um elemento para "x-large":
document.getElementById("demo").style.fontSize = "x-large";
Definição e uso
A propriedade fontSize define ou retorna o tamanho da fonte do texto.
Suporte ao navegador
Property | |||||
---|---|---|---|---|---|
fontSize | Yes | Yes | Yes | Yes | Yes |
Sintaxe
Retorne a propriedade fontSize:
object.style.fontSize
Defina a propriedade fontSize:
object.style.fontSize = "value|initial|inherit"
Valores de propriedade
Value | Description |
---|---|
xx-small x-small small medium large x-large xx-large |
Sets the size of the font to different fixed sizes, from xx-small to xx-large |
smaller | Decreases the font-size by one relative unit |
larger | Increases the font-size by one relative unit |
length | Defines the font-size in length units |
% | Sets the font-size to a % of the parent element's font size |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Detalhes técnicos
Valor padrão: | médio |
---|---|
Valor de retorno: | Uma String, representando o tamanho da fonte do texto no elemento |
Versão CSS | CSS1 |
Mais exemplos
Exemplo
Uma demonstração de valores possíveis:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontSize = listValue;
Exemplo
Retorna o tamanho da fonte de um elemento:
alert(document.getElementById("demo").style.fontSize);
Páginas relacionadas
Tutorial CSS: Fonte CSS
Referência CSS: propriedade font-size
Referência HTML DOM: propriedade da fonte
❮ Objeto de estilo