How do we style HTML elements using the division tag <div>?

HTMLWeb Development

With the <div> tag, easily define a section of your HTML Document. Group large sections of HTML elements together and easily format them. The <div> tag is used with block-level elements.

You can try to run the following code to style HTML element using the <div> tag. The style rule added gets applied to the element with id=”content”.
Here id is the CSS Selector.


Live Demo

<!DOCTYPE html>
      <title>HTML div Tag</title>
      <link rel = "stylesheet" href = "style.css">
      <div id = "container">
         <p>Welcome to our website. We provide tutorials on various subjects.</p>

Here’s the CSS file style.css,

#container p {
   line-height: 15px;
   margin: 20px;
   padding-bottom: 15px;
   text-align: justify;
   width: 130px;
   color: blue;
Published on 01-Feb-2018 13:17:48