HTML or CSS First – Which to Write?

coding-stylecsshtml

There are a lot of analogies for HTML/CSS development; which can be a bit confusing for a beginner.

  • HTML = foundations/house
  • CSS = walls/blueprint/wallpaper

Is there any best practice here? Which one should we write first?

Best Answer

You should build a house first, then paint it.

An HTML document can stand on its own, even though it may look dull. A CSS style sheet cannot; it is nothing displayable (except as code) but instructions for display.

It’s a different issue that during painting, you may wish to do changes to the house. With real houses that’s usually not feasible, but in HTML+CSS development, it’s commonplace to notice that you need extra markup in your HTML document to make styling easier. (It’s less common than it used to be, thanks to powerful CSS3 selectors.)