源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>编程字典</title> <style> .center { text-align: center; border: 3px solid green; } </style> </head> <body> <h2>居中文本</h2> <div class="center"> <p>这个文本是居中的.</p> </div> </body> </html>
运行结果