How to use a div tag in HTML?

Asked By 10 points N/A Posted on -
qa-featured

I am new to HTML and I have a problem understanding the div tag.What is its use and when to use it? Please suggest in detail

about the tag and its functionality.

SHARE
Best Answer by Tunacao_Caaron1
Best Answer
Best Answer
Answered By 10 points N/A #117614

How to use a div tag in HTML?

qa-featured

Hey Spencer Reynoso!

In HTML DIV refers to division in HTML. The purpose of DIV tag is to give a style to block-elements. Every browser, before and after, place a break when we use DIV tag.

Here is a simple code that how can you use DIV tag. However there are many free sites that have the best tutorial for the HTML.

<html>
<body>

<h3>This is a header</h3>
<p>This is a paragraph.</p>

<div style="color:#00FF00">
  <h3>This is a header</h3>
  <p>This is a paragraph.</p>
</div>

</body>
</html>

I would like to recommend you the following link for the help. you can found complete help regarding DIV tag on that website. Here is the link:

http://www.w3schools.com/tags/tag_div.asp

I hope it will help you.

Thanks

 

Answered By 560575 points N/A #117616

How to use a div tag in HTML?

qa-featured

In HTML, the div tag <div></div> is used to define a section or division in an HTML document. It is used to group block-elements so they can be formatted using CSS or cascading style sheet. It is used in pair and should always have the closing tag </div>.

The div tag is supported in all major web browsers such as Google Chrome, Windows Internet Explorer, Mozilla Firefox, Safari, and Opera. The div element is very frequently used together with CSS in laying out a web page. Note: web browsers always put a line break before and after the div element by default. On the other hand, it can be modified using CSS.

The div element can make use of the “align” attribute which can have any of the following values: left, right, center, and justify. In HTML 4.01, all values are accepted. In HTML5, the “left” value has been deprecated or is no longer supported. The example below describes the use of the div element.

<!DOCTYPE html>
<html>
<body>
<p>This text is outside div element.</p>
<div style="color:#F7941D">
<h3>This Heading Is Inside A DIV Element</h3>
<p>This text is outside div element.</p>
</div>
</body>
</html>

Output:

This text is outside div element.

This Heading Is Inside A DIV Element

This text is inside div element.

 

Login/Register to Answer

Related Questions