Make forced line break in title of text widget

I am using text widget in page, my title is too long and i want to make (Br)break in particular place, but i can not. After saving (br)break is gone, also tried (nbsp) but same result came. How to overcome?

Solutions Collecting From Web of "Make forced line break in title of text widget"

You can work around that by passing widget_title through a filter :

function custom_widget_title( $title ) {
    $title = str_replace( '__br__', '<br/>', $title );
    return $title;
add_filter( 'widget_title', 'custom_widget_title' );

Now use __br__ in your widget title instead of <br/> and the code will replace it.

Note: You need to put the code in your theme’s functions.php file.

You can’t use an HTML in the title. Leave the title empty and put the title as part of the HTML of the widget. Apply specific CSS to the widget to make it look like a normal text widget.

Since post_title and post_name (url-part of the page) values depends on each other I will not recommend you using HTML inside page titles. It may leads weird data generated

Title: "foo<br>bar"; 
Slug(URL): "/foobrbar";

, but you can create a meta_field to store HTML and output it.

1) Create a custom field HTML_TITLE_CUSTOM_FIELD_NAME and fill in with your HTML title data;

2) Update your template files changing the title output logic as on example:

   $html_title = get_post_meta($post->ID, "HTML_TITLE_CUSTOM_FIELD_NAME", true);
   if ($html_title) { ?>
      <h1><?php echo $html_title; ?></h1>
   <?php } else { ?>
      <h1><?php the_title(); ?></h1>
<?php } ?>