Why doesn't my CSS link work?

html-css

#1

index.html file

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>PAGINA PRINCIPALA</title>
	**<link rel="stylesheet" type="text/css" href="style.css">**
</head>
<body>
<header>
	<img src="imagini/1.jpg" alt="armenian girl">
	<div id='test'></div>
	<nav></nav>
</header>
<section>
</section>
<footer>
</footer>
</body>
</html>

style.css file

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
/* INCEPUT */
header {
	background-color: #4359a5;
	height: 200px;
	width: 100%;
}
header img {
	margin-top: 10px;
}

I’m trying to create a website loosely based on the first CSS lesson to make sure I can program a website outside of codecademy.com. The HTML sheet works fine but for whatever reason it’s not linking to the css document. The current link is the css file is named style.css both the html and css files are in the same folder. I’m using the Notepad++ text editor to write the code. Any advice I can receive would be much appreciated.


#2

i created both the files, and it works fine.

Are you sure the files are .html and .css? not txt? Right click on the file, and select properties, the window that opens should tell the file type in the bottom, can you upload a screenshot of this? Is it possible for you to upload the files? (through whatever medium you see fit)


#3

Indeed, the css file is actually txt. It only has the name “style.css”

eroare

I would had liked to upload the files too but i’m new here and it seems i’m not allowed.

So how can i change the txt to css?


#4

Suggest separate reset.css from the rest of your styles. Your styles.css should only contain page specific style rules for better reading, maintaining and organization.

https://www.webpagefx.com/blog/web-design/css-reset-stylesheets/

If anything, I would recommend and advise not using reset.css in any of the course material. Until we know the default styles we should not be messing with the default style sheet.


#5

All HTML related files are text. Note the MIME Type:

type="text/css"

Just be sure it has the extension, .css.


#6

you do know that windows xp is no longer a supported operating system?

Well, i would just create new files, when saving the file, below the file name entry field is a file type option, ensure you select all types (this allows you to set extension/file type in the file name)


#7

Made this, still doesn’t work. Could Windows XP be the problem then?


#8

no, windows xp isn’t the problem

did you ensure the files are no longer txt files?


#9

No, i selected ‘all files’ when i’ve saved the files but they still appear as text documents


#10

here are the files:

in the top right is a button which you can use to download the files as zip, just extract them


#11

Man, thanks a lot! It worked! How did you make it a css file?


#12

I created the file on git.github.com, this allows the file extension in the filename

It should work the same with notepad++ (if you select all files as file type, and then specify the extension (.css) in the filename)

you really need to figure out why its not working, and i can’t help you with that, maybe you can watch a video on youtube?


#14

If you are using Notepad to create CSS and HTML files, be sure to set the encoding to UTF-8.


#15

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.