Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to do bold and simple text in the same line using the echo in php?
In PHP, you can combine bold and regular text in the same line using HTML tags within your echo statement. The most effective approach is to use the <strong> tag for bold text and regular text outside it.
Using Strong Tags
The simplest way to create bold text alongside regular text is using the <strong> HTML tag −
<?php echo "<strong>This is bold text</strong> and this is regular text."; ?>
This is bold text and this is regular text.
Using CSS Styling
You can also use CSS font-weight property with <span> tags for more control over styling −
<?php echo '<span style="font-weight: bold; color: #006400;">Bold colored text</span> followed by normal text.'; ?>
Bold colored text followed by normal text.
Mixing with Variables
When combining with dynamic content or variables, concatenate strings properly −
<?php $username = "John"; $score = 95; echo "<strong>User: </strong>" . $username . " <strong>Score: </strong>" . $score; ?>
User: John Score: 95
Conclusion
Use <strong> tags for semantic bold text or <span> with CSS for styled text. Always concatenate strings properly when mixing HTML tags with PHP variables.
Advertisements
