HTML 样式示例 - 背景色
通过 background-color 属性为元素设置背景色:
<html> <body style="background-color:yellow"> <h2 style="background-color:red">This is a heading</h2> <p style="background-color:green">This is a paragraph.</p> </body> </html>
HTML 样式示例 - 字体、颜色和大小
font-family、color 和 font-size 属性对元素中文本文字的字体、颜色及大小进行定义:
<html> <body> <h1 style="font-family:verdana">A heading</h1> <p style="font-family:arial;color:red;font-size:20px;">A paragraph.</p> </body> </html>
HTML 样式示例 - 文本对齐
text-align 属性定义了元素中文本的水平对齐方式:
<html> <body> <h1 style="text-align:center">This is a heading</h1> <p>上面的标题在页面中居中对齐。</p> </body> </html>
HTML 样式示例 - 综合运用
<html> <body> <h1 style="background-color:yellow;text-align:center">This is a heading</h1> <h2 style="background-color:red;text-align:center">This is a heading</h2> <p style="background-color:green;text-align:center">This is a paragraph.</p> <h1 style="font-family:verdana;text-align:center">A heading</h1> <p style="font-family:arial;;text-align:center;color:red;font-size:20px;">A paragraph.</p> </body> </html>
文章为用户上传,仅供非商业浏览。发布者:Lomu,转转请注明出处: https://www.daogebangong.com/articles/detail/HTML-yang-shi-hao-kan-de-yan-se-zi-ti-shi-you-fang-fa-de.html
评论列表(196条)
测试