Is it bad to add html to a widget by closing and reopening the php tags?

“Practice” is a matter of personal preference. The opening and closing PHP tags (<?php and ?>) are there as a matter of convenience. Basically, try to write your code in context. In example,

// PHP code here
?><a href="https://wordpress.stackexchange.com/questions/368897/<?php the_permalink() ?>"><?php the_title() ?></a><?php
// PHP code here

looks (to me) like HTML code plopped right in the middle of a PHP code block (like in a function of the functions.php file), so I will write the display of this HTML link in that context as

// PHP code here
echo '<a href="'. get_the_permalink() .'">'. get_the_title() .'</a>';
// PHP code here

But, if I am in a HTML code block (like in the single.php file of a template), I will write the display of this link in HTML context (as opposed to PHP context above). So, I will not use

// HTML code here
<?php echo '<a href="'. get_the_permalink() .'">'. get_the_title() .'</a>'; ?>
// HTML code here

but instead will code the display of the link as

// HTML code here
<a href="https://wordpress.stackexchange.com/questions/368897/<?php the_permalink() ?>"><?php the_title() ?></a>
// HTML code here

error code: 523