April 3, 200917 yr Hi, one doubt : shall we insert css in body with <style>......</style> tag is it possible? i think only way in insert <style>......</style> in head tag can you clear my doubt?
April 3, 200917 yr This is what you call inline styles... If you are going to style in the body of the page, (Which you shouldnt do anyway) The whole point of CSS is to remove style from markup you would do something like this and apply the style directly to the element. <div style="text-align: left; color: red;">Content here</div> or <h1 style="font-size: 24px; font-family: Verdana, etc etc;">Title here</h1> If you are adament of keeping styles in the page though, yeah you should make all your declarations in the header if possible between the <style type="text/css"></style> Tags. This way come the time you get your brain back from the hospital, you wont have such a headache removing it all and putting it in an external stylesheet.
April 3, 200917 yr The problem with both of these methods is that it defeats the point of using css in the first place. The reason to use css is to produce cleaner code and also keep the style information out of the html so that the html is smaller, easier to read and also a lot easier to edit. Say for example you have 3000 pages and your client wants to change the colour of the headings and the main text on all of these pages, which of these is easier for you to do: 1.)Going through each page and having to find each tag as you have edited them like this<h1 style="color: red;">Content here</h1> to change the colour. 2.) going through each page because at the top you have added your style information to the head tag like this <style type="text/css"></style> and having 3000 times to change the colours 3.) going to the external stylesheet that you have created and changing the colour through this, one page needing to be changed therefore reducing what could have turned into a fairly large job down to a 5 minute job. So my advice is always use an external stylesheet by linking to it in the head tag like this <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
April 3, 200917 yr Agree with Dizi entirely... Have tried to help a few ppl recently who had inline and external css and was HORRIBLE! I really would not do it; it really is no harder to add the styling you want to an external sheet than it is to put it in the html. PLEASE!
April 6, 200917 yr Author Hi Dizi, Thanks for your good support. I know external style sheet's advantage i am always using external css. I was ask this question for a conformation of my knowledge. Thanks, Abhilash. The problem with both of these methods is that it defeats the point of using css in the first place. The reason to use css is to produce cleaner code and also keep the style information out of the html so that the html is smaller, easier to read and also a lot easier to edit. Say for example you have 3000 pages and your client wants to change the colour of the headings and the main text on all of these pages, which of these is easier for you to do: 1.)Going through each page and having to find each tag as you have edited them like this<h1 style="color: red;">Content here</h1> to change the colour. 2.) going through each page because at the top you have added your style information to the head tag like this <style type="text/css"></style> and having 3000 times to change the colours 3.) going to the external stylesheet that you have created and changing the colour through this, one page needing to be changed therefore reducing what could have turned into a fairly large job down to a 5 minute job. So my advice is always use an external stylesheet by linking to it in the head tag like this <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
Create an account or sign in to comment