HTML - 什么是<网页>标签在干什么 [英] HTML - What is the <page> tag doing?
问题描述
CSS
body {
background:rgb(204,204,204);
}
页面{
background:white;
display:block;
margin:0 auto;
margin-bottom:0.5cm;
box-shadow:0 0 0.5cm rgba(0,0,0,0.5);
}
page [size =A4] {
width:21cm;
身高:29.7cm;
HTML
< page size =A4>< / page>
但是,我不确定如何或为什么在CSS中声明页面和页面大小信息你在HTML中使用标签。事实上,我可以在任何地方找到任何对HTML页面标签的引用。
有人可以解释代码在codepen中的工作方式吗?提前致谢 是一个实际的HTML元素。
当浏览器看到这个时,它可能认为它已经老了,错过了当浏览器发布时不存在的新发明。
在这种情况下,它被视为< div>
,并且CSS规则仍然适用。但是真的最好坚持那些真正存在的元素,而不是假装他们有一天会这样做,因为将来新创建的标签的实现可能会与你期望的不同。
最好写成< div class =pagedata-size =A4>
与CSS寻找 div.page
和 div.page [data-size =A4]
。
I've been playing with getting a HTML document to display in A4 size and using the code in this codepen works perfectly:
https://codepen.io/rafaelcastrocouto/pen/LFAes
CSS
body {
background: rgb(204,204,204);
}
page {
background: white;
display: block;
margin: 0 auto;
margin-bottom: 0.5cm;
box-shadow: 0 0 0.5cm rgba(0,0,0,0.5);
}
page[size="A4"] {
width: 21cm;
height: 29.7cm;
}
HTML
<page size="A4"></page>
However, I'm not sure how or why declaring page and page [size information] in CSS allows you to use the tag in HTML. In fact, I can find any reference to a HTML page tag anywhere.
Can someone please explain how the code is working in the codepen? Thanks in advance
I do not believe that <page>
is an actual HTML element.
When the browser sees this, it probably thinks it is getting old and missing out on new inventions that didn't exist when the browser was released.
In that case it is treated like a <div>
, and CSS rules still apply.
But really it's best to stick to elements that really exist, instead of pretending they will some day, because in the future the implementations of newly created tags could be different than you expect.
It would have been better to be written as <div class="page" data-size="A4">
with the CSS looking for div.page
and div.page[data-size="A4"]
.
这篇关于HTML - 什么是<网页>标签在干什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!