Inheritance in CSS

 HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="style.css">
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Inheritance Demo</title>
    <link rel="stylesheet" href="inheritance_style.css" />
  </head>
  <body>
    <body>
      <h1>Main Heading</h1>
      <div>
        <h2>Heading 1</h2>
        <form>
          <label>username: </label>
          <input type="text" placeholder="username" />
          <label>password: </label>
          <input type="password" placeholder="password" />
          <button>Login</button>
        </form>
        <hr />
      </div>

      <div>
        <h2>Heading 2</h2>
        <p>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Nesciunt
          inventore saepe, reiciendis dolorem illo culpa velit odio pariatur,
          officia ad veniam itaque adipisci veritatis quos tenetur. Ut autem
          dolores mollitia!
        </p>
        <hr />
      </div>
    </body>
  </body>
</html>

CSS

div{
    background-color: aquamarine;
}
/* h3 and p tags  will inherit bg color from div  */

input{
    background-color: inherit;
}
button{
    background-color: inherit;
}

Comments

Popular posts from this blog

Assignment

OverFlow

FRONT-END PROJECT SPOTIFY CLONE