How to Adjust Font Size Script
Adjusting font sizes in your Web pages accentuates areas of your pages. Javascripts are used to change the font size after a user clicks a button or hovers over an area of your web page. This is beneficial when you want some text to stand out on the page and trigger user input. Javascript has a "font" property that is used to manipulate font styles, including the pixel size.
Instructions
-
-
1
Open the HTML file you want to edit in a text editor. You can use an editor as simple as Notepad, or use more advanced editors, such as Visual Studio and Notepad++, which color code your tag changes.
-
2
Locate the element you want to be your font size trigger. For instance, in this example, the font size changes when the user hovers over a hyperlink tag. Add the "onMouseOver" event property to the tag. The following adds the property to an HTML element:
<a href="my_domain.com" onMouseOver="">Click Here</a>
-
-
3
Add the Javascript code that changes the font size. The following code changes the font size of a paragraph to 15 pixels when the user hovers over the hyperlink:
<a href="my_domain.com" onMouseOver="javascript:p.fonSize='15px'">Click Here</a>
-
4
Save the file changes and open the file in your Web browser. Hover over the hyperlink to test the changes and verify that the font size changes.
-
1
References
- Photo Credit internet - eingabefeld internet http://www image by pmphoto from Fotolia.com