<style> use in head ? Why ? | Sololearn: Learn to code for FREE!

+3

<style> use in head ? Why ?

I have learn with challenge that style’s tag can be used in head but i don’t understand why and the utility to make it Thanks for answer :)

2/8/2019 8:21:55 AM

Axel Slb

10 Answers

New Answer

+7

Style tag is used for CSS. We can add CSS to a page in three ways, external, internal and inline. When we put <style> in head (recommended way), we actually add CSS internally. It's often used when we want to make specific change to the page that is already being affected by external CSS, because priority of internal is higher than that of external For example when you add bootstrap.css as external CSS to all your html pages, you may want to make font size of your contact.html a little bigger instead of what is defined in bootstrap.css. If you edit bootstrap.css, you'll see all pages affected, but adding internal style will affect that particular page only.

+5

Yes it's recommended. But putting it in <body> is OK too

+5

Axel Salenbier you can use it in both <head> and <body>. But it's better to use in <head>.

+4

https://code.sololearn.com/W5Nq53nYiG8j/?ref=app Take a look here, as u can see all paragraphs will have color yellow and later you can easily change it just there. Inline styles you should use only for styling particular thing on a page. In head/style you will create classes and style all elemetnts on a page

+3

<style> SHOULD be used in head by right.

+2

thanks :)

+2

Okay thanks for your help ^^

+2

Firstly prefer external css,which is used in head section. Secondly it is not the preferred way to write inline css in the body section. Thirdly for the Readability and Modularity thing because it will make more efficient and would look more professional by using style tag in head section.

+1

it’s recommended ? i think the better way was to create an external css

+1