It is a <head> tag that is a regular tag that is not displayed by default.

I noticed that when viewing a webpage in Chrome, the <head> had CSS assigned {display: none;} .

This made me think that the <head> is a regular tag that browsers cannot display.

Even if this didn’t make obvious sense, I could instead use the <head> tag instead of the <cheese> tag and use the css "cheese {display: none;}" to achieve the same function as the <head> tag <head> ?

+8
html
source share
3 answers

<head> and display:none

Yes, the <head> tag is a regular tag, like any other, with a default user style sheet and display:none; To her. I can do the trick to prove that this shows your styles:

jsFiddle

 head, style { display:block; } 

For added pleasure, you can add contenteditable to your title so you can edit the page styles on the page.

jsFiddle

<cheese>

As for creating some random tag, such as <cheese> , this does not work (well, maybe not) as expected, because the browser does not expect it. When you do something in HTML that is not in the specification, it cannot be processed in the standard way.

An example of this is an attempt to use the new semantic HTML5 tags ( <section> , <nav> , ...) in older versions of IE, they do not recognize them and do not fool the page up. The cast in Modernizr uses some polyfields to fix this and emulate the regular <div> .

+5
source share

In terms of pure display - yes {display:none;} will hide your element.

However, HTML <head> has a clear meaning in HTML as a container for header elements, whereas <cheese> does not share it.

Browsers know that it is not displayed, and search robots understand the special meaning of the <head> .

+2
source share

The browser displays the body of the document, which is contained in the pairs of <body></body> tags. This is the part of the document that is displayed and displayed.

HTML defines its own set of tags and attributes that make up the language. A document type declaration (DTD) determines which set of tags and attributes are used by a subdocument. Therefore, when your DTD is for HTML5, you use tags and attributes specific to HTML5 (or rather you should and the browser should do the same).

So, if you want to add your own tag to the mix, for example say <cheese> , you can place it anywhere in the document, if it is in the pairs of the <body></body> , most likely the browser will make the tag literally (since it is not part of HTML and does not know what to do with it).

If you must add it before the <body></body> tags, then your document will not be well-formed (that is, it will not follow the rules of the type of an HTML document), however this will not affect what the browser displays.

0
source share

All Articles