Jump to content

css


hisoka

Recommended Posts

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

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

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 by proudly
Link to comment
Share on other sites

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

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>
  • Like 1
Link to comment
Share on other sites

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

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 by hisoka
Link to comment
Share on other sites

<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

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.

  • Like 1
Link to comment
Share on other sites

< 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">

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...