The HTML <div> tag is used for defining a section of your document. With the div tag, you can group large sections of HTML elements together and format them with CSS.
The attributes of DIV include:
Id – Specifies a unique id for an element
-
- ID’s are unique
i. Each element can have only one ID
ii. Each page can have only one element with that ID
-
- Syntax
<element id=”id“>
e.g.: <div id=”page-wrapper”>
<div id=”main-wrapper”>
<div id=”main-content” style=”margin-left: 20px; margin-right: 20px ;”>
Class – The class attribute specifies one or more class names for an element. Any styling information that needs to be applied to multiple objects on a page should be done with a class.
-
- Classes are NOT unique
i. You can use the same class on multiple elements.
ii. You can use multiple classes on the same element.
-
- Syntax
<element class=”classname“>
e.g.: <div class=”portlet-header”>Report Filters and Options</div>
<div class=”portlet-content”>
<div class=”Other-box gray-box float-left width100 display-inline”>
Style – The style attribute specifies an inline style for an element.
i. The style attribute will override any style set globally (e.g. styles specified in the <style> tag or in an external style sheet)
-
- Syntax
<element style=”style_definitions“>
e.g.: style=”padding-left: 0px; padding-right: 0px; vertical-align: middle”>
The PHP code should be enclosed within the PHP tags. This can be done in 2 ways:
i. <?php <code> <?>
ii. <? <Code> ?>