Using Div and Span in HTML

0
1137

<div> and <span> are used in HTML to format and provide layout to the HTML pages.

<div> – It simply defines a division or we can say section in a HTML document. It is basically used to group elements and format them with either css or tags attributes. The main use of <div> tag is to define the proper layout of our HTML page. We can use either “Class” or id for this.

<span>
The <span> tag is used when we have to format a single word means either have to change color, size, and font of a single word. Like other tags in HTML span tag are also used because it is supported by maximum browsers.it basically groups all the inline element of a document.

Working Example

This is what we want to create

Capture

Here in the code above by using the <span> tag we can format the single word. Just like here “TRY” is colored with GREEN color.

This code above has been used to design the left part of our page.Here I used <div> tag to divide my webpage according to my requirement and changes the attributes also like height,width of that portion. You can try changing the dimension and check the output.

The code written in this part is used to write the content we want to enter in the portion we defined in the right part of our page.We formatted the data according to what we wanted.

The code output will be same as what we wanted initially.

LEAVE A REPLY

Please enter your comment!
Please enter your name here