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
25 Replies
like is this alr and why does my main-mains.css and why won t it connect to others file for example?
this is what i have rn
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
what does it do?
and does it work with all code or just html and css?
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#deferwhat is defer and why script:
Read the link I sent you
You might need to configure it to format on save
why does it matter?
and see nowhere script:
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
elementoh prettier seems to do nothing
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
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?
Typically I, and others, format html like this
It depends but if your site is small enough I'd just keep it in 1 file
alr better to read yeah
Question is a bit complicated honestly haha
but for example don t want this body for my other files but just a body for the background color
gonna sleep now gonna go to uni early tom and it is almost midnight here
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
Hi
Im not aloud to use divs
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.