I am using Windows (7) trying to create an offline html page that should link to a separate CSS file located in same directory. I tried to use
<link rel="stylesheet" type="text/css" href="/styles.css" />
but no luck.
And I also want to import another css file named styles2.css within style.css. Didn't check yet but putting @import "style2.css";
on style.css may be not work as well. I can use absolute links like C:\Users\ELITEBOOK\Desktop\offline\style.css
but it won't work if I move the folder anywhere else from Desktop. Any help? I mean, any code that calls/adds the link of the folder?
If both HTML and CSS files are in the same folder, enter only the file name. Otherwise, include the folder name in which you store the CSS file. media – describes the type of media the CSS styles are optimized for. In this example, we put screen as the attribute value to imply its use for computer screens.
CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.
CSS and HTML are best kept separate so that the CSS is uniformly accessible to all pages on a site, not just the document it is included in. Integrating CSS into webpages is an inefficient way to style a site.
I always tend to store my css in directories under the root folder. Which would contain all my ie6 specific overrides. It is all personal preference though, pick whichever style suits you.
Use <link rel="stylesheet" type="text/css" href="./styles.css" />
instead. Note: href="/styles.css"
changed to href="./styles.css"
, which is current directory of your script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With