What is relative and absolute in external CSS? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is relative and absolute in external CSS?

I want to know how to use an external CSS. i tried setting the rel and href to (filename) but the css file is not working can any one help me? thank you

9th Aug 2017, 2:38 PM
Damon Keane
5 Answers
+ 5
@Melih Melik Sonmez: I think you missunderstood the question and that title of question is related to description ^^ @Damon Keane: An external Css file is linked to the Html document using: <link href="url_to_file.css" rel="stylesheet" type="text/css"> The 'rel' attribute stand for 'relation' and not for 'relative' ;P Anyway, what's relative and absolute in that stuff is the url (the internet path to the file ressource)... An absolute url is one starting with the protocol ('http;//', 'ftp://', 'file://' and so on), giving explicit complete path from the hosting internet domain name (the reference to the server computer hosting the file). A relative url is one wich don't set explicit reference to the server domain name, but implicitly use the url of the html file as starting point for the path to the file... Let say your html file is opened with absolute url: "http://mydomain.org/folder/file.html" Then, any relative url used in 'href' or 'src' attributes will be relative to "http://mydomain.org/folder/", so if you set href="/another_folder/style.css", the absolute implicite url will be: "http://mydomain.org/folder/another_folder/style.css", meaning that you have this kind of directory structure on your server: + www |--+ folder |--+ file.html |--+ another_folder |--+ style.css ... assuming that the domain "mydomain.org" target the "www" folder/directory on your server ;)
9th Aug 2017, 4:52 PM
visph
visph - avatar
+ 2
thanks 👍
9th Aug 2017, 2:48 PM
Damon Keane
+ 2
yw
9th Aug 2017, 2:48 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
+ 2
😊😊😊
9th Aug 2017, 4:57 PM
Damon Keane
0
Both of them used for referance point of object one of them from top left corner of page the other one from top left corner of ITS own place so while when you take ref for page it is 0,0 but the other one where object is but the title of your question and its content is not related
9th Aug 2017, 2:46 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar