First of all, remember that html is for adding meaning and css appearance.
If you want to change the text size for sematic reasons, like “this text is a subsection title” or “this sentence is very important”, I would advice you not to use <span style="font-size: xx">
. It’s a better practice for those cases to use <strong>
, <em>
or a proper heading tag and then change your theme’s css to customize its appearance up to your likings.
If it’s not for semantic but for presentational reasons, you are ok with <span style="font-size: xx">
.
To make it easier, you can use the following code to add a new button to the text editor that will let you choose the font size without having to hardcode it each time.
Just copy the code to a new file, save it as show-font-size-button-in-editor.php
and install and activate it as a plugin. Alternatively you can copy the function
and add_filter
to your theme’s functions.php
file.
<?php
/*
Plugin Name: Show font size button in editor
Description: Adds a font size selector to the TinyMCE first tools row
Version: 0.1
Author: WPSE
Author URI: http://wordpress.stackexchange.com/questions/225895/how-can-i-change-the-size-of-the-text-in-word-press
*/
defined( 'ABSPATH' ) or die( 'Method not allowed.' );
function wpse225895_show_font_size_button_in_editor( $buttons ) {
array_unshift ( $buttons, 'fontsizeselect' );
return $buttons;
}
add_filter( 'mce_buttons', 'wpse225895_show_font_size_button_in_editor', 10, 1 );
?>