locked
set font sieze programmatically with textarea RRS feed

  • Question

  • hello

    i am trying to set the font size of a text area programmatically without success

     mytextarea.style.fontsize=25+ "px"

    Tuesday, May 1, 2012 9:47 AM

Answers

  • Hi

    When using the font-size attribute as a javascript property please use a capital "S" as in "fontSize"

    eg

    mytextarea.style.fontSize=25+"px";

    or

    mytextarea.style.fontSize="25px";

    Also while I enjoy trying to answer question I have a bad feeling it is slowing you down. So in a case like this I would open something like this page :

    HTML and DHTML Reference

    and click on the link that says

    DHTML Properties

    then scroll down to "fontSize", open the page, read it and look for an example.

    Having said that, please feel free to post questions anytime. Trying to answer questions probably helps me just as much as it helps you or anyone else.

    • Marked as answer by marck68 Tuesday, May 1, 2012 12:38 PM
    Tuesday, May 1, 2012 10:15 AM
  • Btw, you may also have to adjust the lineHeight property at the same time - and give it a couple of extra px. But you can experiment with the both of them.

    eg

    mytextarea.style.fontSize="24px";

    mytextarea.style.lineHeight="28px";

    • Marked as answer by marck68 Tuesday, May 1, 2012 12:38 PM
    Tuesday, May 1, 2012 11:09 AM

All replies

  • Hi

    When using the font-size attribute as a javascript property please use a capital "S" as in "fontSize"

    eg

    mytextarea.style.fontSize=25+"px";

    or

    mytextarea.style.fontSize="25px";

    Also while I enjoy trying to answer question I have a bad feeling it is slowing you down. So in a case like this I would open something like this page :

    HTML and DHTML Reference

    and click on the link that says

    DHTML Properties

    then scroll down to "fontSize", open the page, read it and look for an example.

    Having said that, please feel free to post questions anytime. Trying to answer questions probably helps me just as much as it helps you or anyone else.

    • Marked as answer by marck68 Tuesday, May 1, 2012 12:38 PM
    Tuesday, May 1, 2012 10:15 AM
  • Btw, you may also have to adjust the lineHeight property at the same time - and give it a couple of extra px. But you can experiment with the both of them.

    eg

    mytextarea.style.fontSize="24px";

    mytextarea.style.lineHeight="28px";

    • Marked as answer by marck68 Tuesday, May 1, 2012 12:38 PM
    Tuesday, May 1, 2012 11:09 AM