HTML <style>

Not open for further replies.
Hi all im new to html im teaching myself and ive also looked at css now my question is css used for formatting color and background color then what does the <style> attribute in html used for are they both the same ????
Hi Riches.
The Style tag allows you to specify the same items such as background colour, fonts etc directly in the page itself as would be specified in a css file.
The obvious difference is that when the CSS file is included in the <head> section of your pages, the styles are applied to all your pages (once imported to each page) from the CSS file and you do not have to retype the styles for every page i.e. iif a change is made in the CSS file to say the font colour of the H1 tag it is applied automatically to every page on your site.

Importing a CSS file is the recommended method of applying styles to your pages so I wouldn't bother with the style tag, as the xhtml standard has deprecated it (if I remember correctly). If you want to have some pages different from other pages in your site simply import a different css file for these pages or you wish to have a different style applied for how your pages are printed or shown on a mobile device you can import more than one style sheet into the same page(s).

Hope this helps,

Not open for further replies.
Award-winning Mac antivirus and Internet security software