How HTML, CSS and JavaScript work
together in web pages
The three main technologies used to
create modern web pages (HTML, CSS and JavaScript) each do different
jobs.
HTML
should be used only for structuring content.
Cascading Style Sheets
should be used for applying all visual styles.
JavaScript
should be used for (almost) all interactive functionality, and should
always be referenced in separate files, never written into HTML.
The web page you see in your browser
may be a combination of structure, style and interactivity. These jobs
are undertaken by 3 different technologies, which your browser knows
how to interpret.
Different HTML tags describe the
structure of content. Each one has its own meaning, and you should only
ever use each one in accordance with its meaning, and in its proper
place.
When people talk about "semantic"
HTML, this is what they mean.
This simply means: Don't put
JavaScript or CSS in your HTML. Put them in separate files, called in
by your HTML pages.