How HTML, CSS and JS work together

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, HTML, Javascript, and CSS which your browser knows how to interpret.

A web page may combine structure from HTML, style from CSS and functionality from JavaScript

HTML
marks the content up into different structural types, like paragraphs, blocks, lists, images, tables, forms, comments etc.
CSS
tells the browser how each type of element should be displayed, which may vary for different media (like screen, print or handheld device)
JavaScript
tells the browser how to change the web page in response to events that happen (like clicking on something, or changing the value in a form input)

The 2 most important things to learn about web page production are:

  1. Use the correct HTML tags that mean what they say.
  2. Keep your HTML, CSS and JavaScript code separate.

1. Use HTML properly

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.

In the HTML section, I’ll explain what each tag means, and where it’s OK to use it.

2. Keep ‘em separate

This simply means: Don’t put JavaScript or CSS in your HTML. Put them in separate files, called in by your HTML pages.

There are lots of good reasons for this, the main ones being:

  • It’s more logical and simpler. And simple is good.
  • Easier management: Keeping all your styles and functional code in one place makes it quicker, easier and safer to change in future.
  • Easier re-purposing: It’s easier to design your web site to look or work differently on different user agents (e.g. handheld browsers, audio browsers, or TV)

Make Better Web Pages!

How to make your web site sell - use my secrets

Find out How

Do you love our approach to crafting simple & effective web sites that just work for people?

We'd love to hear about your web strategy.

Contact one of our team today!

Leave a comment

Articles + tutorials in HTML / CSS

Complete List of HTML/xHTML Tags, With Guide to Proper Semantic Use
My Complete List of HTML/xHTML Tags, With Guide to their Proper Semantic Use
Semantic HTML Handbook – Benefits of Writing Semantic HTML
Free article on Semantic HTML. Why you should learn Semantic HTML. Benefits for SEO and code reuse explained.
A Few Tips and Tricks to Write Better Semantic HTML
Tips and tricks for writing better semantic HTML or xHTML from a professional web producer
Building a web page with HTML & CSS for complete beginners
Learn what HTML is and how to build a website from scratch. A guide to creating a web page using HTML and CSS for people with no prior knowledge
Keeping your content in order of priority with flexible CSS layouts.
How to keep your most important content at the top of your page, no matter what kind of column layout you wish to achieve.
Web page production with xHTML and CSS (ebook)
Introduction to Semantic HTML
A Basic Guide to writing semantically correct semantic HTML or xHTML markup
Anatomy of HTML/xHTML tags
HTML basics tutorial: Learn HTML tags, covering the most common attributes
Introduction to Cascading Style Sheets (CSS)
Beginner's introduction to Cascading Style Sheets (CSS), learn CSS.
Making a Tabular list in HTML
Create an appealing tabular list using HTML, CSS and JavaScript
How HTML, CSS and JavaScript work together in web pages
Best practice for using HTML, Cascading Style Sheets, and JavaScript together to make web pages.
HTML Tables – when and how to use tables in HTML
When to use tables in HTML, and how to do it properly
Block vs Inline display style in CSS
An article explaining the differences between block and inline display property in CSS. Gives examples of CSS Block vs Inline CSS and how they are applied in CSS/HTML files and pages.
Datasheet-style form using HTML and CSS
Make a datasheet-style web form using HTML, CSS and JavaScript
Inheritance and Cascading Styles in CSS Explained
Introduction to CSS inheritance and how styles apply in CSS through inheritance and cascading. Read this guide detailed guide on using CSS inheritance.
HTML Lists: unordered, ordered and definition lists
My guide to HTML lists explains the 3 main types of lists web browsers support and how to implement them in HTML / xHTML
HTML, how to code HTML/xHTML markup
Free HTML tutorials: Learn top-quality web page production skills using HTML/xHTML markup
Using CSS (Cascading Style Sheets)
Free tutorial on learning CSS for web design and development
Introduction to HTML – basics of HTML
Introduction to basic HTML tags and the structure of HTML documents.
© Scratchmedia Limited, 2006-2010
Floor 3, 111 Buckingham Palace Road, London, SW1W 0WQ, UK
+44 (0)207 1600 989