0

What is the specify of internal stylesheets located in the body element (wrapped in style tags). By nature of their location within the page it would appear they have precedence over internal and external stylesheets located within the head element.

Is the following accurate?

  1. inline
  2. internal in body
  3. internal and external in head
  4. browser default

I guess my second question is if the above is correct, how does one override internal css located in the body? Add stylesheet to footer, somehow?

Edit: For clarity this is a variation of the the following question and accepted answer answer:

CSS Specificity - External Stylesheet vs Internal Stylesheet using just classes

  • Are you assuming the exact same selector in each of these style sheets? (Generally you should aim to override rules with the selector rather than how the stylesheet is added) – DBS Mar 24 '21 at 16:11
  • Yes, I should have been more specific, exact same. this is a variation to the question and accepted answer of https://stackoverflow.com/questions/52073885/css-specificity-external-stylesheet-vs-internal-stylesheet-using-just-classes – supertravelguru Mar 24 '21 at 16:47
  • The behavior of internal styles in body is not defined because – BoltClock Mar 24 '21 at 17:31
  • Thanks @BoltClock, this is helpful, so I guess source order continues from head to body to footer. Your point about style in body not being valid is well noted, this discussion in https://stackoverflow.com/questions/2830296/using-style-tags-in-the-body-with-other-html seems to otherwise, reference https://www.w3.org/TR/html52/document-metadata.html#the-style-element – supertravelguru Mar 24 '21 at 17:57
  • @supertravelguru: That Q&A was posted during the brief period in which style in body *was* valid. I should've been clearer and said that it's *no longer* valid. Would you like me to post an answer? I refrained previously because I'd mod-deleted another answer for breaking the rules... – BoltClock Apr 21 '21 at 03:30

0 Answers0