473,790 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
What html code do I use to offer viewers of my webpage different text sizes?
Feb 7 '11 #1
2 2401
Frinavale
9,735 Recognized Expert Moderator Expert
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
Markus Igeland
14 New Member
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
2479
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 HTML as text, which I do, then I have trouble because the XSLT processor (SAXON) outputs everything as one continuous line. How can I make the HTML output from SAXON readable? Is there a command in the XSLT language that forces line breaks? ...
5
4113
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> to Enter Railways Online); } else {
4
1554
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 intended in virtually any browser (according to browsercam), except for IE 5.x/Win and Opera 6/Mac, where the huge text size breaks the layout (as can be seen on
18
25007
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, that IE7 does not seem to offer any way to control the font size of a text input element.
4
6790
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
1484
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 possible platforms (PC, Mac, UNIX, …) and browsers (Safari, IE, Netscape, …) or at least as many as possible. 2.b) I use as well hyphens (in names with hyphens for hyphenation, etc.) as en-dashes - for a comment within a text like this one - and also...
1
2899
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 file which includes some html code to populate html formatted content as the text of an asp:label (<asp:label>). The reading of the text file itself goes just fine ;however, this only occurs when I use an absolute file path which will not work of...
7
1928
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 on the foreign site. However, the information I got back was nonsensical. I'm guessing the code I get back from the web page is written in that foreign language, but when I -> of the same page, it looks like normal html code. Does anyone know...
2
3060
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. contactus.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.