How do I increase and decrease text size on a web page using PHP, CSS, or JQuery?
3 Answers
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.
2
-
1While 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
Set text-size on the text container (a p, a div, a span, ...).
<p style='font-size:120%'>
$("#divs_id_that_I_want_to_increase_text").css("font-size", "22px");