Block vs Inline, div, span and Entities
Every element is either block or inline.
- Block elements start on a new line and take the full width:
<div>,<p>,<h1>,<ul>,<section>. - Inline elements sit inside a line of text and take only the space they need:
<span>,<a>,<strong>,<img>.
Knowing whether an element is block or inline explains many layout surprises: why two divs stack on top of each other, why a link sits inside a sentence, or why setting a width on a span does nothing. CSS can change this behaviour with the display property, which you'll learn in the CSS course.
<!DOCTYPE html>
<html>
<head>
<style>
div { background: #dbeafe; margin: 4px 0; }
span { background: #fde68a; }
</style>
</head>
<body>
<div>I am a block. I take the whole width.</div>
<div>Me too.</div>
<p>This sentence has an <span>inline span</span> in the middle.</p>
</body>
</html>▶ Try it yourselfdiv and span
<div> and <span> have no meaning of their own. They are boxes you use to group things for CSS or JavaScript: div for blocks, span for words inside a line. When a meaningful tag exists (<nav>, <article>, <button>), prefer it.
HTML entities
Some characters have a special job in HTML, so you write them as entities:
Entities exist because < and > are how the browser recognises tags. If you want to show the symbol itself (for example in a tutorial about HTML, like this one!), you must write it as an entity so the browser doesn't think a tag is starting.
<shows < and>shows >&shows &"shows " inside an attribute is a space that never breaks the line ("₹ 500" keeps ₹ and 500 together)©shows ©,→shows →
<p>In HTML, write <p> to start a paragraph.</p>
<p>Tom & Jerry</p>
<p>Price: ₹ 500</p>
<p>© 2026 My Shop</p>▶ Try it yourself<meta charset="UTF-8"> you can type most symbols directly (₹, ©, emojis). You still need entities for <, > and &.- Block elements start on a new line; inline elements sit inside text.
- div and span are meaning-less boxes for grouping.
- Write < > & to show < > &.
