FMTechnical notesPortfolio
Back to the blog

Frontend · Beginner

HTML, CSS, and JavaScript: a complete web from scratch

HTML defines meaning, CSS decides presentation, and JavaScript adds behavior. A solid interface respects those responsibilities before adding frameworks.

After reading this
  • Write semantic HTML
  • Build adaptable layouts
  • Change visible state with JavaScript
01 / 03

Three layers, three jobs

HTML describes what things are. CSS controls how they look in different contexts. JavaScript reacts to events and changes data or interface.

  • A button performs an action; an anchor navigates.
  • Use Grid for two-dimensional composition and Flexbox for a row or column.
  • Listen to events instead of embedding logic inline.
02 / 03

A component without a framework

The DOM already provides a basic component API. Model clarity matters more than the tool.

html
<button id="counter">Clicks: 0</button>
<script>
  let count = 0;
  const button = document.querySelector('#counter');
  button.addEventListener('click', () => {
    button.textContent = `Clicks: ${++count}`;
  });
</script>
03 / 03

Responsive from content

Prefer fluid sizes, max-width, and media queries where the content actually breaks. Do not design only for a list of devices.

css
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
}
HTML and CSS playground● interactive
index.html · edit live
Practice

Edit and observe

Add a second card in the playground and make a button change its color.

Show a hint

Select the card with querySelector and toggle a class.