在網站開發中,HTML和CSS是不可或缺的兩個東西。HTML用來描述網頁的結構和內容,CSS則用于控制網頁的樣式和布局。
<!DOCTYPE html> <html> <head> <title>Hello World</title> <style> body { background-color: #f5f5f5; font-family: Arial, sans-serif; font-size: 16px; color: #333; margin: 0; padding: 0; } h1 { font-size: 32px; text-align: center; margin-top: 50px; } p { line-height: 1.5; text-align: justify; margin: 20px 50px; } .header { background-color: #0078d7; height: 60px; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; } .logo { font-size: 24px; font-weight: bold; } .nav { display: flex; align-items: center; } .nav a { color: #fff; text-decoration: none; margin-left: 20px; } </style> </head> <body> <header class="header"> <div class="logo">My Website</div> <nav class="nav"> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </nav> </header> <h1>Hello World!</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam euismod felis vel neque blandit, a sagittis velit suscipit. Donec eu dolor purus. Mauris id arcu ipsum. Donec vulputate, nibh ac vestibulum imperdiet, arcu libero venenatis elit, non faucibus nisl odio eget dui. Sed porttitor turpis vitae lectus lobortis, at ultricies sapien interdum. Duis mollis dui augue, et congue ligula gravida in. Donec leo tellus, ornare a consectetur vel, convallis non dolor. Mauris ante turpis, finibus ac odio in, scelerisque malesuada risus. Etiam congue ipsum ultricies sollicitudin consectetur. Sed viverra ornare arcu, tristique ullamcorper eros aliquam quis.</p> </body> </html>
以上是一個簡單的HTML和CSS代碼示例,其中使用了一些常用的CSS樣式,如background-color、font-size等等。在實際網站開發中,會使用更加復雜的CSS樣式來實現更加豐富的網頁效果。
上一篇mysql32中文下載
下一篇html css文本樣式