-1

How do I increase and decrease text size on a web page using PHP, CSS, or JQuery?

4
  • 1
    Using jQuery: $("#divs_id_that_I_want_to_increase_text").css("font-size", "22px");
    – Cipi
    Jul 27, 2010 at 10:42
  • I assume this question is about accessibility, and increasing the text size globally across all elements, and with the site remembering across different pages. Hence the answers below are pretty useless....
    – cjk
    Jul 27, 2010 at 10:49
  • @ck so I assume you have an answer which uses php?
    – How to
    Jul 27, 2010 at 10:50
  • nope, I've never done this. I just use the zoom buttons on my keyboard....
    – cjk
    Jul 27, 2010 at 10:51

3 Answers 3

3

You can increase text size on the whole page (for all elements that inherit text size from the 'body') with:

function setFontSize(size) {
    $('body').css('font-size', '' + size + 'px');
}

Demo here.

0

Check the font-size CSS property

Reference: http://www.w3.org/TR/CSS2/fonts.html#font-size-props

2
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. Aug 1, 2015 at 4:33
  • @pinkalvansia that is the page of the World Wide Web Consortium (W3C). Pretty sure it will not change ;) Aug 1, 2015 at 10:35
0

Set text-size on the text container (a p, a div, a span, ...).

<p style='font-size:120%'>
1
  • text-size? is this a new css style? Jul 27, 2010 at 10:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.