Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it valid HTML to have two <style> elements inside your HTML <head> tag?

Tags:

html

css

styles

Is it valid to have two <style> tags inside of an HTML head tag?

For example I am trying to write an HTML page for email clients with no external stylesheets added. Due to the way our template system works it is much easier for us to have

<head>
 <style>
  .someStyle{}
 </style>
 <style>
  .someOtherStyle{}
 </style>
</head>

instead of this...

<head>
 <style>
  .someStyle{}
  .someOtherStyle{}
 </style>
</head>

If option 2 is the only way of doing this I will do that but option 1 for various reasons works better for our framework code.

like image 741
benstpierre Avatar asked Jul 26 '12 20:07

benstpierre


People also ask

Can you have two style tags in HTML?

You can add multiple styling properties at once when using the HTML style attribute - just make sure to separate the name-value pairs with commas. Using a separate stylesheet is very convenient for styling multiple pages, as it's easier to apply changes to one document than to each page separately.

Can you have two heads in HTML?

Technically HTML documents are not allowed to have multiple <head> sections, but sites which aggregate content from multiple sources sometimes have them.

How many head elements can a valid HTML document have?

It is inappropriate to cite this document as other than work in progress.” But the principle is the same in all HTML specifications and drafts: exactly one head element is allowed per document.

What should be inside head in HTML?

The <head> element is a container for metadata (data about data) and is placed between the <html> tag and the <body> tag. Metadata is data about the HTML document. Metadata is not displayed. Metadata typically define the document title, character set, styles, scripts, and other meta information.


1 Answers

It's perfectly fine to have multiple style elements in between your <head> and </head> tags. You can have as many as you want, together with <link> or <script> elements.

like image 115
knittl Avatar answered Oct 10 '22 08:10

knittl