HTML Tags and Elements
Attributes and Hyperlinks
Headings and Lists
Class and id attributes
Inline and Block-Level Elements
Div and Span
What is the function of <div> element in HTML?
This is the very important block level tag which plays a big role in grouping various other HTML tags and applying CSS on group of elements. It acts as a container for other elements.
What are the attributes that can be used with div element?
Although <div> element doesn’t require attributes but there are three common attributes that can be used-
<head> <title>HTML div Tag</title> </head>
<div style = "color: green">
<h1>This is first group</h1>
<p>Following is a list of sports </p>
Output: This is first group Following is list of sports-
Explain <span> element in HTML.
The span element is used as a container for text. Like <div>, it does not require attributes. Style, class and id are the commonly used attributes.
The <span> element is used to style a certain text within a larger text element.
<title>HTML span Tag</title>
<p>This is my <span style = "color:red">first assignment</span>.I am <span style = "color:purple">learning </span></p> a lot from it.
Output: This is my first assignment. I am learning a lot from it.