473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

What html code do I use to offer viewers text size options (ex., sm, med, lg text)?

What html code do I use to offer viewers of my webpage different text sizes?
Feb 7 '11 #1
2 2379
Frinavale
9,735 Expert Mod 8TB
Is your web page static or is it dynamically created by a server side script?

Are you permitted to use JavaScript in your solution.

Typically you would use CSS to set the font-size for your web page.

For example, if you want your page's content to be small font size you might have the following css:

Expand|Select|Wrap|Line Numbers
  1. body{
  2.   font-size:small;
  3. }
For medium:
Expand|Select|Wrap|Line Numbers
  1. body{
  2.   font-size:medium;
  3. }
For large:
Expand|Select|Wrap|Line Numbers
  1. body{
  2.   font-size:large;
  3. }
Now the thing is that you need to apply the CSS to your page when the user indicates that they want to change the font size.

You could submit the page to sever-side code which would apply the corresponding font-size-css style to the value that the user selected.

Or you could use JavaScrpt to change the font-size css style....

Or you could redirect the user to a page that is exactly the same but uses the font-size style that the user selected.

-Frinny
Feb 7 '11 #2
This is a solution using jQuery, and my preferable way of doing it (because it's small and fast and everyone on the Internet already have jQuery in their cache).

CSS-code:
Expand|Select|Wrap|Line Numbers
  1. .smalltext { font-size: small; }
  2. .mediumtext { font-size: medium; }
  3. .largetext { font-size: large; }
  4.  
JavaScript-code:
Expand|Select|Wrap|Line Numbers
  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript">
  2. <script type="text/javascript">
  3. $(#small).onclick(function(){${'body').addClass('smalltext');});
  4. $(#medium).onclick(function(){${'body').addClass('mediumtext');});
  5. $(#large).onclick(function(){${'body').addClass('largetext');});
  6. </script>
  7.  
HTML-code (snippet):
Expand|Select|Wrap|Line Numbers
  1. <a href="#" id="small" class="smalltext">aA</a>&nbsp;
  2. <a href="#" id="medium" class="mediumtext">aA</a>&nbsp;
  3. <a href="#" id="large" class="largetexttext">aA</a>
  4.  
Feb 17 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jaydog | last post by:
Hello... I'm new to XSL, and I've written a XSLT file that converts a XML file to HTML format. When viewed in a browser, it appears exactly as I would like. However, if I want to look at the...
5
by: Joe Patrick | last post by:
On my websites index.html page I have this script: <SCRIPT language="JavaScript"> <!-- // if ((screen.width==1024) && (screen.height==768)) { document.write('<a href="active.html">Click here</a>...
4
by: Der Kommissar | last post by:
Hi all I've been working on a site, in which I had to use tables for layout, but I've used CSS to style the text and a few other things. http://www.cultuurnet.be/ The site seems to work as...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
4
by: usgog | last post by:
Here is my html code snippet: <html> <style type="text/css"> option:hover { background:#e5ecf9; } </style> <table> <tr><td>
2
by: sono | last post by:
1. I am looking which HTML CODE is AS GENERAL AS POSSIBLE (i.e. independant of platform and browser). 2. To be more explicit : 2.a) I am writing HTML code which I would like to run on ALL...
1
by: cnixuser | last post by:
Hello, I am having a problem that I believe is related to the way a stream reader object looks for a text file by default. What I am doing is using a StreamReader object to read the text of a text...
7
by: alnoir | last post by:
I'm working on this script that grabs a web page from a foreign site, searches it for specific information, and grabs web pages from links on the original page. Once I had it working, I tried it out...
2
by: sateeshchandrasanga | last post by:
Hi All, My HTML code is working fine in Firefox.But its not displaying any thing in IE.Can you help me in this problem.And in Google crown its displaying but not properly. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.