Horje
How to bold text in PHP?

Bold Text is used in web applications to highlight important information or headings. In this article, we will learn to bold text in PHP using two possible approaches with implementation.

Below are the approaches to bold text in PHP:

Using the <b> tag from HTML

In this approach, we are using the <b> tag from HTML directly within PHP’s echo statement to render text in bold. The text wrapped within <b> tags is styled as bold, as shown in the example where “Hello GFG! I am Bold Text in PHP” is displayed in bold.

Example: The below example uses <b> tag from HTML to bold text in PHP.

PHP
<?php
echo "<h1>Approach 1: Using the tag from HTML</h1>";
echo "<p>Hello GFG! I am Not Bold Text</p>";
echo "<p><b>Hello GFG! I am Bold Text in PHP</p></b>";
?>

Output:

Screenshot-2024-04-11-at-17-06-22-W3Schools-online-PHP-editor

Using Inline CSS

In this approach, we are using inline CSS within PHP‘s echo statement to apply the font-weight: bold; style to a <span> element, resulting in bold text. The text “Hello GFG! I am Bold Text in PHP” is rendered in bold due to the inline CSS styling applied to the <span> element.

Example: The below example uses Inline CSS to bold text in PHP.

PHP
<?php
echo "<h1>Approach 2: Using Inline CSS</h1>";
echo "<p>Hello GFG! I am not Bold Text in PHP</p>";
echo "<p><span style='font-weight: bold;'>
Hello GFG!I am Bold Text in PHP</span> </p>";
?>

Output:

Screenshot-2024-04-11-at-17-10-32-W3Schools-online-PHP-editor




Reffered: https://www.geeksforgeeks.org


PHP

Related
PHP Exercises, Practice Questions and Solutions PHP Exercises, Practice Questions and Solutions
How to Set Time Delay in PHP ? How to Set Time Delay in PHP ?
How to Return JSON from a PHP Script ? How to Return JSON from a PHP Script ?
How to JSON Decode in PHP? How to JSON Decode in PHP?
How to Remove First Element from an Array in PHP? How to Remove First Element from an Array in PHP?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
14