hisoka Posted March 12, 2015 Share Posted March 12, 2015 my journey in CSS begins now : in this link http://www.w3schools.com/css/css_intro.asp , it is written : The style definitions are normally saved in external .css files. With an external style sheet file, you can change the look of an entire Web site by changing just one file! suppose we have a website in which there are hundred of pages . We take the css file and put in another folder . Now we want to change the color of one sentence in a paragraph in the page number 65 . How is this possible by using an external css file ?? Link to comment Share on other sites More sharing options...
davej Posted March 12, 2015 Share Posted March 12, 2015 It can't be done in the css file. You would have to edit the page 65 html file and enter a local <style> block in the head of that file _OR_ change the link in that file to point to a different css file. Link to comment Share on other sites More sharing options...
proudly Posted March 12, 2015 Share Posted March 12, 2015 (edited) in your ''number 65.html'' you have to add a connection with your css file also a class for the paragraph eg classp1 . If your css file has the name ''mycssfile.css'', you have to add that in the html <link rel="stylesheet" href="mycssfile.css" title="style1" /> also in your css file you have to refer to the class for your paragraph eg .classp1{ color:green; } Edited March 13, 2015 by proudly Link to comment Share on other sites More sharing options...
Ingolme Posted March 13, 2015 Share Posted March 13, 2015 in your ''number 65.html'' you have to add a connection with your css file also a class for the paragraph eg classp1 . If your css file has the name ''mycssfile.css'', you have to add that in the html <link rel="stylesheet" href="mycssfile.css" title="style1" /> also in your css file you have to refer to the class for your paragraph eg .class1{ color:green; } Why do you have a title attribute on your <link> element? Link to comment Share on other sites More sharing options...
proudly Posted March 13, 2015 Share Posted March 13, 2015 just to name it (is taken from one of my codes). But i think that is working, althought davej said that can't be done with css Link to comment Share on other sites More sharing options...
davej Posted March 13, 2015 Share Posted March 13, 2015 To clarify -- if you have sixty-five different HTML files that all begin with... <!DOCTYPE html><html><head><meta charset="utf-8"><title>title</title><link rel="stylesheet" type="text/css" href="mystyle01.css"></head><body> ...then they all look at the file mystyle01.css and if you want to change the style of page65.html then you can edit that file so that it looks at a different css file... <!DOCTYPE html><html><head><meta charset="utf-8"><title>p65 title</title><link rel="stylesheet" type="text/css" href="mystyle_for_p65.css"></head><body> ...OR you can modify the styling with a local style like this... <!DOCTYPE html><html><head><meta charset="utf-8"><title>p65 title</title><link rel="stylesheet" type="text/css" href="mystyle01.css"><style>h1{background-color: green;margin: 15px;}</style></head><body> 1 Link to comment Share on other sites More sharing options...
proudly Posted March 13, 2015 Share Posted March 13, 2015 I mean that : your 65 html <!DOCTYPE html><html><head><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="mystyle01.css"></head><body> <p class="class1p"> some text</p> </body> </html> and the in the css file (common for all the html's) .classs1p{ background-color: green;margin: 15px; } Is that working? Link to comment Share on other sites More sharing options...
hisoka Posted March 13, 2015 Author Share Posted March 13, 2015 (edited) let me sum up if we have , say 100 html page , in order to affect them with my , say mystyle.css file , all what I need to do is to include it in every page of my hundred html pages . Meanwhile if I want only one paragraph in the sixty-five html page to be affected all what I need to do is to make a css file specific for that page , say mystyle65.css , and include it only in my sixty-five html page. Is this what you mean davej? the inclusion process is like you wrote in your little piece of code : <link rel="stylesheet" type="text/css" href="mystyle.css"> if the mystyle01.css is , say in http://w3schools.invisionzone.com/web/example/mystyle01.css why we do not do like this : <link rel="stylesheet" type="text/css" href="http://w3schools.invisionzone.com/web/example/mystyle.css"> and like this for the sixty - five page <link rel="stylesheet" type="text/css" href="http://w3schools.invisionzone.com/web/example/mystyle65.css"> ?? Edited March 13, 2015 by hisoka Link to comment Share on other sites More sharing options...
dsonesuk Posted March 13, 2015 Share Posted March 13, 2015 You should never need to do this, you would either use a new class/id, or you could use id or class reference higher in hierarchy so it would override current lower hierachy styling.Idea is to use as less css style sheets as possible. Link to comment Share on other sites More sharing options...
hisoka Posted March 13, 2015 Author Share Posted March 13, 2015 <link rel="stylesheet" type="text/css" href="mystyle.css"> the link tag defines a link between HTML document and the external css file . href specifies the location of the css document. If the document is in http://w3schools.inv...om/web/example/mystyle.css" then why we do not include the complete url that specifies the location of the css document instead we include only the name of the css document . This was my question ?? Link to comment Share on other sites More sharing options...
dsonesuk Posted March 14, 2015 Share Posted March 14, 2015 Because if you use absolute path which in includes domain etc, everytime you move it to another domain or to your local test server, it will reference the file from the domain you moved it from.Using relative path, it reference the file from its current location from root directory using '/mytemplates/css/mycssfile.css' or if css file is in same location as html files 'mycssfile.css' would suffice. 1 Link to comment Share on other sites More sharing options...
proudly Posted March 14, 2015 Share Posted March 14, 2015 < then why we do not include the complete url that specifies the location of the css document instead we include only the name of the css document . This was my question ?? Lets say that you want to make a website . Create a directory with the name Mywebsite. Put there all your files , including css, html, js, and wwhateve.Upload your directory to a server. Then is enough to ''call '' by using <link rel="stylesheet" type="text/css" href="mystyle.css"> 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now