Unknown Type Selector “button1” 是什么意思?

huangapple go评论83阅读模式
英文:

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

   &lt;button1 id=&quot;coolbutton&quot; type=&quot;button&quot;&gt;

        My JSFiddle Account

      &lt;/button1&gt;

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)。

例如,它定义了buttonhtml。它不定义button1,而且button1不符合自定义元素的格式。

您尝试在您的HTML中创建一个button1元素,这是无效的HTML,会触发浏览器中的错误恢复。

您已经编写了一个CSS类型选择器来尝试选择它,而报告错误的工具知道您正在尝试在不允许button1元素的HTML文档中查找元素。

请使用idclass属性来定义特定的(或一组特定的)元素。根据元素的语义选择类型。不要发明新的类型。

英文:

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

没有&lt;button1&gt;元素,你要找的只是&lt;button&gt; &lt;/button&gt;。在coolButton id上应用你的CSS(或者你想要修改的按钮的id)。

英文:

there is no &lt;button1&gt; element what you are looking for is simply the &lt;button&gt; &lt;/button&gt;. Do your CSS on the coolButton id (or the id of the button you want to change)

huangapple
  • 本文由 发表于 2023年2月18日 00:59:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75487177.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定