Hi, I inserted this code: echo '<h2 style="display: inline;">Payment Type:</h2><p style="display: inline;"> ' . $order->get_payment_method_title() . '</p>'; PHP: And I want to break a line at the end of the paragraph. I tried to add <br> tag in several ways, but it doesn't work! Like this : echo '<h2 style="display: inline;">Payment Type:</h2><p style="display: inline;"> ' . $order->get_payment_method_title() . '</p>' . '<br>'; PHP: Or like this: echo '<h2 style="display: inline;">Payment Type:</h2><p style="display: inline;"> ' . $order->get_payment_method_title() . ',<br> ' . '</p>'; PHP: What is the correct way to insert the <br> tag in the first code? Thank you,
Is this some assignment or something? Why can't you just put it right after </p>? Put two for good measure. echo '<h2 style="display: inline;">Payment Type:</h2><p style="display: inline;"> ' . $order->get_payment_method_title() . '</p><br><br>'; Code (markup):
If all you really want is some white space after the paragraph try adding margin-bottom echo '<h2 style="display: inline;">Payment Type:</h2><p style="display: inline; margin-bottom: .25em;"> ' . $order->get_payment_method_title() . '</p>'; Code (markup): or it might just be that the <br> needs to be <br /> but the right way is to use the style (or even better a class). Does the display: inline make sense to you? paragraphs are inline already.
Thank you @ qwikad.com & @ sarahk for your replies, Yes, the display: inline makes sense, because I want to display the information in one row. I set '</p><br><br>' And it seems to work properly. Thanks for your help,
except that paragraphs are already inline. What have you got in the method title that would stop that from happening?
1) why are you crapping style into the markup violating the separation of concerns? 2) why would you use a BR to do margin's job? There's no thematic break in flow there. 3) if they're inline the margin should be ignored, try inline-block. 4) Float might be better here too. float:left; the heading and let the paragraph just do its thing. No extra code needed. 5) this almost looks like tabular data or a candidate for definition lists, not a heading and paragraph. The paragraph in particular since "payment type" is highly unlikely to be one or more complete sentences forming a singular thought. Remember, P is for grammatical paragraph. Not a snippet of text, not something you just want a line break after, but a PARAGRAPH. 3rd grade English, PARAGRAPH!
Hi @deathshadow, The "inline-block" worked too. But "float:left;" did not work in this case. Thank you very much,
crapping inline styles in (which should NEVER be done) this doesn't fly? echo ' <h2 style="float:left;">Payment Type:</h2> <p style="margin-bottom:1.5rem;">', $order->get_payment_method_title(), '</p>'; Code (markup): Also killing off the garbage string addition, adding whitespace to make output debugging easier, etc, etm. So long as something else in your existing styles isn't interfering, that should do the job as good if not better. NOT that this looks like a heading and a paragraph.
Absolutely! There are a couple of ways to insert the <br> tag correctly: 1. Simplest Way: Inside the closing </p> tag, just before it: echo '<h2 style="display: inline;">Payment Type:</h2><p style="display: inline;">' . $order->get_payment_method_title() . '</p><br>'; 2. Newline within String: You can also add a newline character (\n) within the string displayed by the <p> tag: echo '<h2 style="display: inline;">Payment Type:</h2><p style="display: inline;">' . $order->get_payment_method_title() . "\n" . '</p>'; Both methods will achieve the line break after the payment method title.