The <div> tag defines sections on an HTML page and is used to group other elements. It has no inherent styling but can be styled using classes, IDs, or inline styles. Any content can be placed inside a <div> tag, which browsers separate with line breaks. Examples are provided of using <div> tags with inline and external styles to format text sections with different backgrounds and fonts.
2. HTML <div> Tag
• The <div> tag defines a division or a section in an HTML document.
• The <div> tag is used as a container for HTML elements
• The <div> tag is easily styled by using the class or id attribute.
• Any sort of content can be put inside the <div> tag!
• Note: By default, browsers always place a line break before and after the
<div> element.
4. <html>
<head>
<title>The div Tag</title>
</head>
<body>
<h1> The div Tag </h1>
<div style="background-color:#8ebf42">
<p>We use the tag to group two paragraphs for applying a background to
the text, and to add color to this
</p>
</div>
</body>
</html>