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)

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

To make your web project a success, contact Scratchmedia for Great Web Design - guaranteed!

Search this site
Pro Tips
Learn how to make fantastic web site designs..
Buy "Save the Pixel" now!
On “Save the Pixel”
Clicss templates, great robust useful CSS templates from £40
Share this Article
Send to a friend now&hellip
Follow Ben Hunt on Twitter
Floor 3
111 Buckingham Palace Road
London
SW1W 0WQ
UK
Phone
+44 (0)207 1600 989

Articles + tutorials in HTML & CSS Production

Overview
Menu of all our articles on HTML, CSS and web page production
CSS
List of our CSS articles
Introduction to CSS
Beginner's introduction to Cascading Style Sheets (CSS)
HTML
List of HTML articles
Introduction to HTML
Introduction to basic HTML tags and the structure of HTML documents.
How HTML, CSS and JavaScript work together in making web pages
Best practice for using HTML, Cascading Style Sheets, and JavaScript together to make web pages.
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
Block vs Inline display style in CSS
HTML elements can be displayed either in block or inline style. The difference between these is one of the most basic things you need to know in order to use CSS effectively.
Inheritance and Cascading Styles in CSS
Introduction to how styles apply in CSS through inheritance and cascading.
HTML Lists
The basics of lists: unordered, ordered and definition lists covered.
HTML Tables
The basics of tables. When to use tables, and how to do it. Includes tips on colspan and rowspan properties, and the col and colgroup tags.
Anatomy of HTML tags
Describes the common attributes that can feature in your HTML tags.
Introduction to Semantic HTML
Explains what semantic HTML, or semantically-correct HTML, is and how it benefits web development.
Semantic HTML Handbook - Benefits of Writing Semantic HTML (Nov 15 2009)
Free article on Semantic HTML. Why you should learn Semantic HTML. Benefits for SEO and code reuse explained.
Complete List of HTML/xHTML Tags, With Guide to Proper Semantic Use (Nov 15 2009)
My Complete List of HTML/xHTML Tags, With Guide to their Proper Semantic Use
A Few Tips and Tricks to Write Better Semantic HTML (Nov 15 2009)
Tips and tricks for writing better semantic HTML or xHTML from a professional web producer
Web Page Production using xHTML and CSS (ebook)
This new 61-page ebook provides a worked example of web production, taking you through the entire process from a Photoshop page design, to a working HTML page template.
Datasheet-style form using HTML, CSS and JavaScript
Make a datasheet-style web form using HTML, CSS and JavaScript
Tabular list-style form using HTML, CSS and JavaScript
Create an appealing tabular list using HTML, CSS and JavaScript
Complete HTML tag reference
Our complete guide to HTML and xHTML tags, and their proper usage.
Keeping your content in order of priority with flexible CSS layouts
This article shows you how to use CSS floats to achieve any column layout, while keeping your most important content highest on the page.