将CSS属性设置为html标签正确吗? [英] Is correct to set CSS property to html tag?

查看:90
本文介绍了将CSS属性设置为html标签正确吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上可以设置html标签的背景颜色。我不知道这是有可能的,我也不知道它在逻辑上是否正确,我认为正文是唯一负责包含的内容,并且是第一个呈现的标签。我以为html标记只是一个包装,但看起来却有所不同。因此,

I can actually set the background-color of the html tag. I didn't know it was possible and I don't understand if it's logically correct, I thought the body was the only one responsable to contain and the "first" rendered tag. I thought html tag was just a wrapper but it looks different. So,



  • 究竟是什么表示html标签?

  • 为什么可以设置背景色吗?

  • 会给我带来麻烦吗?

我将主体的大小调整为1024 x 768,并希望将其背景颜色设置为白色,而将html页面设置为黑色,这种方式非常好...我想知道是否必须使用div为此(我讨厌很多div!)

I resized body to a 1024 x 768 size and want to set its background color to white, while html page to black, it's quite nice in this way... I would like to know if I must use div for this (I hate a lot of divs!!!)

推荐答案

浏览器呈现它那样。实际HTML元素上的样式非常好。实际上, HTML 4的默认样式表设置了< html> 元素显示为:阻止。它是一个可见元素,并且可以被程式化。

A browser will render it that way. Styles on the actual HTML element are perfectly fine. In fact, the default style sheet for HTML 4 sets the <html> element to be display: block. It is a visible element and it can be stylized.

在根元素中添加样式不会改变其语义,而只会改变它的语义。显示。只要您不改变元素的语义,就可以了。别客气。

Adding styles to the root element doesn't change its semantic meaning, only how it's displayed. As long as you're not altering the semantic meaning of elements, you're fine. Style away.

这篇关于将CSS属性设置为html标签正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆