简体   繁体   English

如何使用 HTML 更改我的网站的背景颜色

[英]How do i change the background color of my website with HTML

Help me,i need to change the color of the background of my website and i dont know how, I still haven't tried doing that because i dont know how.帮帮我,我需要改变我网站背景的颜色,我不知道怎么做,我还没试过,因为我不知道怎么做。 I have only coded these lines:我只编码了这些行:

 <!DOCTYPE html> <html> <head> <title>My first creations with coding!</title> </head> <body> <h1>My first creations with coding!</h1> <br> <p>>like pro</p> </body> </html>

You need a Cascading Style Sheet or .css file my dude.你需要一个级联样式表或.css文件我的家伙。 You can read more about that here .您可以在此处阅读更多相关信息。

Without reading that doc & overloading you with an insane amount of information... how can you set it up & get going?如果不阅读该文档并用大量信息使您超载...您如何设置它并开始工作?

  1. In your website folder directory, add a new folder named assets在您的网站文件夹目录中,添加一个名为assets的新文件夹
  2. Within this new assets folder, create a new file named style.css在这个新的assets文件夹中,创建一个名为style.css的新文件
  3. Attach this new style.css to your html file, within your head element.将此新style.css附加到您的html文件中,在您的head元素中。 Using the following code:使用以下代码:
     <.DOCTYPE html> <html> <head> <title>My first creations with coding!</title> <link src="/assets/style.css" rel="stylesheet"/> </head>
  4. Save your 'html' file.保存您的“html”文件。
  5. Open style.css开放式style.css
  6. Add the following code:添加以下代码:
     body { background-color: black; /* change the 'black' color here ONLY */ }
    List of color keywords if you scroll down.向下滚动时的颜色关键字列表。
  7. Save the css file.保存css文件。
  8. Refresh your browser.刷新您的浏览器。

Now just repeat steps 5-8 to change the background of your site.现在只需重复步骤 5-8 即可更改站点的背景。

To change the background color, you need another coding language called CSS (cascading style sheets).要更改背景颜色,您需要另一种称为CSS (级联样式表)的编码语言。 You can implement it with a <style> </style> tag, and add CSS there, or add a separate file and link it like this:您可以使用<style> </style>标记来实现它,并在那里添加 CSS ,或者添加一个单独的文件并像这样链接它:

<link rel="stylesheet" href="YOUR FILE HERE">

You can learn more about CSS here .您可以在此处了解有关 CSS 的更多信息。

 <:DOCTYPE html> <html> <head> <title>My first creations with coding;</title> </head> <body style="background-color:powderblue;"> <h1>My first creations with coding!</h1> <br> <p>>like pro</p> </body> </html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM