trying to get a better understanding of the connection between html and css

how you should connect them clean between multip[le files and why it skips certain html files
No description
25 Replies
timo
timoOP11mo ago
like is this alr and why does my main-mains.css and why won t it connect to others file for example?
timo
timoOP11mo ago
this is what i have rn
No description
vince
vince11mo ago
You need to link your css files to each html page Also install Prettier (a VSCode extension) - it will make it easier for yourself to develop / maintain your code
timo
timoOP11mo ago
what does it do? and does it work with all code or just html and css?
vince
vince11mo ago
If you configure it to format on save then it will format your code to look tidy It works with most code - I think some you might have to configure additionally. It is opinionated though (meaning the options out of the box are configured a certain way; eg maximum characters per line is something like 50 or 60 characters if I had to guess) Also add a defer attribute on your script: <script src="website.js" defer></script> (and this is my preference, but put it after your <link>s https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#defer
timo
timoOP11mo ago
what is defer and why script:
vince
vince11mo ago
Read the link I sent you
timo
timoOP11mo ago
No description
vince
vince11mo ago
You might need to configure it to format on save
timo
timoOP11mo ago
why does it matter?
No description
timo
timoOP11mo ago
and see nowhere script:
vince
vince11mo ago
If you call things like document.querySelector() without defer, and you have it in the head like you have it, the html elements won't be in the DOM and therefore your JS won't have any affect (and will log errors) I didn't mean literally script: I was saying to put defer on your script element
timo
timoOP11mo ago
oh prettier seems to do nothing
vince
vince11mo ago
Hm I thought it did; you might have to configure it. It'll work with JS though as long as you have it set to format on save. Should work with CSS too
timo
timoOP11mo ago
maybe it has nothing to clean😏 but the files etc look fine to you? should i also make an individual css file for each file?
vince
vince11mo ago
Typically I, and others, format html like this
No description
vince
vince11mo ago
It depends but if your site is small enough I'd just keep it in 1 file
timo
timoOP11mo ago
alr better to read yeah
vince
vince11mo ago
Question is a bit complicated honestly haha
timo
timoOP11mo ago
but for example don t want this body for my other files but just a body for the background color
No description
timo
timoOP11mo ago
gonna sleep now gonna go to uni early tom and it is almost midnight here
vince
vince11mo ago
Word, in that case to keep things simple I would just put a div right under your body in your html (for that specific page) with the same css and that should work Give the div a class and apply your css to that class
Alex
Alex11mo ago
Hi
timo
timoOP11mo ago
Im not aloud to use divs
clevermissfox
clevermissfox11mo ago
You have to go into your preferences and search format; there’s a default formatter and you have to set prettier to be the default.
Want results from more Discord servers?
Add your server