Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Coloring the head in html

Is it possible to color the head in an html file?

I tried doing the same thing you do to color the body,
<body style="background-color:rgb(255, 255, 255);">.
I did the same with the head,
<head style="background-color:rgb(40, 40, 40) ;">.
But I ran the file and it doesn’t work.

-Any help is appreciated.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Disclaimer: I am a complete beginner when it comes to html.

>Solution :

You can, but it doesn’t do you any good unless you cause the <head> to be rendered (it is, by default, display: none).

document.title="Example"; // Setting the title with JS because this is a Stack Snippet which expects the HTML provided to go in the <body>
head {
    display: block;
    background: pink;
}

title {
    display: block;
}

Generally speaking, there shouldn’t be anything in the <head> that you should want to be rendered.

It contains metadata about the document, not the document content itself.

Consequently, this rarely makes any sense except as an exercise in proving that CSS can touch any bit of markup in a page.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading