Try to use this:
<link rel="stylesheet" type="text/css" href="css/style.css" >
instead of
href="../css/style.css
Here you are missing right apostrophe. Also check BalusC answer would solve your problem.
Note:
Also i recommend to you create resources folder on the same level as WEB-INF then in resources folder create css folder and then reference css file as:
WEB-INF
resources
--css
--styles.css
--js
--scripts.js
and here how to connect css with page:
<link rel="stylesheet" type="text/css" href="resources/css/styles.css" />
I'm using this approach is my web project and everything works correctly.
Answer from Simon Dorociak on Stack OverflowTry to use this:
<link rel="stylesheet" type="text/css" href="css/style.css" >
instead of
href="../css/style.css
Here you are missing right apostrophe. Also check BalusC answer would solve your problem.
Note:
Also i recommend to you create resources folder on the same level as WEB-INF then in resources folder create css folder and then reference css file as:
WEB-INF
resources
--css
--styles.css
--js
--scripts.js
and here how to connect css with page:
<link rel="stylesheet" type="text/css" href="resources/css/styles.css" />
I'm using this approach is my web project and everything works correctly.
The @import rule is another way of loading a CSS file:
<style>
@import url('/css/styles.css');
</style>
you can import all the styles at the same time using this trick, like:-
@import url('/css/header.css') screen;
@import url('/css/content.css') screen;
@import url('/css/sidebar.css') screen;
@import url('/css/print.css') print;
I can't link my CSS and I think I'm going insane
CSS not working in stylesheet - Stack Overflow
html - What is the reason for rel='stylesheet'? - Stack Overflow
<link rel="stylesheet" type="text/css" href="../styles.css"> not working
Videos
<link rel="stylesheet" type="text/css" href="styles.css">
The html and css are in the same folder. What am I missing here? I've done this many times before and I'm starting to think I'm going crazy. Please save me! Thanks :)
This is just a shot in the dark as (at the time of this post) you haven't provided source code.
Make sure you're linking to your stylesheet using a link tag in the head of the HTML document.
If you had:
<style type="text/css">
/* <![CDATA[ */
#someid
{
margin: 0;
padding: 3px 12px;
}
/* ]]> */
</style>
You'll need to have
#someid
{
margin: 0;
padding: 3px 12px;
}
in your CSS file with:
<link rel="stylesheet" type="text/css" href="path/to/style.css" />
to link to the stylesheet.
Some common newbie mistakes include:
<style type="text/css" src="path/to/style.css">: because it's a similar syntax to the<script>tag, which would make sense, but is invalid<link rel="stylesheet" src="path/to/style.css">: butlinkelements use href not src- placing
linkelements within the body: although browsers will tend to managelinkelements in the body, there are likely going to be some errors, and it's not a defined behavior - not specifying a doctype declaration: allows the browser to go into quirks mode, which is never a good idea.
You should make sure the stylesheet is properly imported.
Sometimes the @import doesn't work well if not used accordingly, so always reference your stylesheet:
<link rel="stylesheet" type="text/css" href="name-of-stylesheet.css" />
Always remember to close the <link> tag as it's a self-close tag. I think @zzzzBov forgot to mention that.
Finally, if that doesn't work, try to override some of the styles by physically writing (above the </head> section) something like:
<style type="text/css">
body { background: blue; }
* { color: red; }
</style>
and see if that gives you a blue background and red colored text. It should. After that, try to implement the referencing method and make sure you reference the stylesheet file to the right directory.
Good luck!
The rel='stylesheet' attribute is used to define the relationship between the linked file and the current HTML document.
The rel stands for "relationship", and is probably one of the key features of the <link> element — the value denotes how the item being linked to is related to the containing current document.
The current HTML document needs to tell the browser what you were linking to using the rel tag, otherwise the browser would have no idea what to do with the content you're linking to.
There are many different kinds of relationship. Like @cee
You will find the list of some of Link types in the following links
Refer this link for more details from MDN
<link tags are not inherently CSS style sheets. There are lots of link types, for example <link rel="icon" href="favicon.ico">.
If you didn't tell the browser what you were linking to via rel, then the browser would have no idea what to do with the content you're linking to.