英文:
What does Unknown Type Selector "button1"?
问题
我更擅长 C++ 和纯 JS,但感觉非常愚蠢找不到答案。
我尝试了这个:
<button1 id="coolbutton" type="button">
我的 JSFiddle 账户
</button1>
再配合这个 CSS 代码:
button1 {
font-family: Verdana;
color: purple;
background-color: grey;
text-align: center;
text-decoration-line: overline underline;
}
html {
background-color: #666699;
}
body {
background-color: #666699;
}
对于我的“史诗级编码技能”感觉不太好,因为我觉得这比我想象的要简单。
英文:
Im more of a C++ and plain JS type of dude, and I feel absolutely stupid not being able to find this out.
I tried doing this
<button1 id="coolbutton" type="button">
My JSFiddle Account
</button1>
along with this CSS code
button1 {
font-family: Verdana;
color: purple;
background-color: grey;
text-align: center;
text-decoration-line: overline underline;
}
html {
background-color: #666699;
}
body {
background-color: #666699;
}
Not feeling so good about my "Epic Coding Skills" because I feel like it's easier than I think.
答案1
得分: 1
《HTML Living Standard》(https://html.spec.whatwg.org/multipage/)定义了HTML中存在的元素类型(以及命名自定义元素的格式(https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name)。
例如,它定义了button
和html
。它不定义button1
,而且button1
不符合自定义元素的格式。
您尝试在您的HTML中创建一个button1
元素,这是无效的HTML,会触发浏览器中的错误恢复。
您已经编写了一个CSS类型选择器来尝试选择它,而报告错误的工具知道您正在尝试在不允许button1
元素的HTML文档中查找元素。
请使用id
和class
属性来定义特定的(或一组特定的)元素。根据元素的语义选择类型。不要发明新的类型。
英文:
The HTML Living Standard defines what element types exist in HTML (along with a format for naming custom elements.
It defines, for example, button
and html
. It does not define button1
, and button1
does not meet the custom element format.
You have tried to create a button1
element in your HTML, which is invalid HTML and triggers error recovery in browsers.
You have written a CSS type selector to try to select it, and whatever is reporting that error knows you are trying to find an element in an HTML document where button1
elements are not allowed.
Use id
and class
attributes to define specific (or groups of specific) elements. Select the type based on the semantics it has. Don't invent new types.
答案2
得分: 1
没有<button1>
元素,你要找的只是<button> </button>
。在coolButton id上应用你的CSS(或者你想要修改的按钮的id)。
英文:
there is no <button1>
element what you are looking for is simply the <button> </button>
. Do your CSS on the coolButton id (or the id of the button you want to change)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论