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.

Example

Live Demo

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

Here’s the CSS file style.css,

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