Advertisement
Checkmark

Change Text Size HTML/JavaScript

Oct 27th, 2019
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.52 KB | None | 0 0
  1. HTML code to add buttons
  2.  
  3. Add id="body" to the body tag.
  4.  
  5.   <body id="body" >  
  6.  
  7. Add code for the buttons:
  8.  
  9.   <button type="button" onclick="bigger()">Bigger</button>
  10.   <button type="button" onclick="smaller()">Smaller</button>
  11.  
  12. JavaScript Code to change font size:
  13.  
  14.     <script>
  15.         function bigger(){
  16.             document.getElementById('body').style.fontSize='x-large';
  17.         }
  18.         function smaller(){
  19.             document.getElementById('body').style.fontSize='medium';
  20.         }
  21.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement