How to change the font color and size in PHP?
In PHP, you can use HTML tags to modify the color and size of fonts. Here are some examples of code:
<?php
echo '<h1 style="color: red; font-size: 24px;">Hello World!</h1>'; // 修改字体颜色为红色,字体大小为24px
?>
You can also manage styles using CSS by defining the styles in an external style sheet and applying them to HTML elements. Here is an example code:
<?php
echo '<link rel="stylesheet" type="text/css" href="styles.css">'; // 引入外部样式表
echo '<h1 class="custom-heading">Hello World!</h1>'; // 使用自定义样式类修改字体颜色和大小
?>
Define your styles in the styles.css file.
.custom-heading {
color: red;
font-size: 24px;
}
I hope this can help you!