3 Replies - 738 Views - Last Post: 14 June 2012 - 07:45 AM

#1 codecook  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 16-July 11

Properly linking stylesheet questions

Posted 14 June 2012 - 07:19 AM

I have already read in multiple areas that the proper way to link a external stylesheet is placing something like "<link rel="stylesheet" type="text/css" href="http://www.mycss.css" />" in the head of the document. However, I currently can only place that line in the body and it works fine.

My question is, is it only a matter of time before browsers may stop supporting linking items in the body and I should really try to figure out a way to put link the CSS in the head?

Second question is, if I define the same exact selector in two different linking stylesheets with 2 different paramaters, will the one further down always overwrite the top stylesheet?

e.g.

<link rel="stylesheet" type="text/css" href="http://www.mycss.css" /> ---- p {color:green;}
<link rel="stylesheet" type="text/css" href="http://www.mycss2.css" /> ---- p {color:red;}

Will <p> now always(unless otherwisedefined by html in document) be red?


Thanks!!

This post has been edited by codecook: 14 June 2012 - 07:20 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Properly linking stylesheet questions

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4142
  • View blog
  • Posts: 13,098
  • Joined: 08-June 10

Re: Properly linking stylesheet questions

Posted 14 June 2012 - 07:22 AM

View Postcodecook, on 14 June 2012 - 04:19 PM, said:

Second question is, if I define the same exact selector in two different linking stylesheets with 2 different paramaters, will the one further down always overwrite the top stylesheet?

AFAIK, that is a set rule in CSS.
Was This Post Helpful? 1
  • +
  • -

#3 codecook  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 16-July 11

Re: Properly linking stylesheet questions

Posted 14 June 2012 - 07:41 AM

View PostDormilich, on 14 June 2012 - 07:22 AM, said:

View Postcodecook, on 14 June 2012 - 04:19 PM, said:

Second question is, if I define the same exact selector in two different linking stylesheets with 2 different paramaters, will the one further down always overwrite the top stylesheet?

AFAIK, that is a set rule in CSS.



Thanks for confirming my second question.

Do you know what the issue with the 1st question? Is it still supposed to work fine in the body of the document and is only recomended to use in the Head because of some caching issue so it does not have refetch the css ?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4142
  • View blog
  • Posts: 13,098
  • Joined: 08-June 10

Re: Properly linking stylesheet questions

Posted 14 June 2012 - 07:45 AM

as far as my experience goes, browsers will try their best to render any served HTML code, no matter how invalid it is. I donít think they will ignore <link>s in the wrong place anytime soon.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1