HTML div tag
Note: If you don't know what a tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.
Description
The HTML div tag allows authors to assign certain attributes to blocks of contents. It's primary used in conjunction with style sheets to give visual styles to portions of content in a document. Also, the "id" attribute gives a way to dynamically change these attributes with or without the user interaction. Browsers usually place a break line before and after a div block, so if you are looking for an in-line version check the HTML span tag.
Attributes
id (name)
The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element.
Example:
Code begin
<p id="paragraph1">This is the first paragraph named as paragraph1. To dynamically change its properties use this identifier.</p>Code end
<p id="paragraph1">This is the first paragraph named as paragraph1. To dynamically change its properties use this identifier.</p>Code end
class (cdata)
The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It's used with style sheets and tells the browser the class to which the element is associated with. A class gives visual attributes to elements.
Example:
Code begin
<p class="references">This article is based on the book "Wind in the trees" by Jhon L. Brooks</p>
<p class="references important">This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.</p>Code end
<p class="references">This article is based on the book "Wind in the trees" by Jhon L. Brooks</p>
<p class="references important">This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.</p>Code end
style (style)
Defines a visual style of this element. Is a better practice to define styles attributes in external style sheets grouping them in classes. Attributes in the "style" parameter must preserve this order "name : value" and be separated by a semi-colon.
If you're writing XHTML code it's recommended not to use this attribute and try style sheet classes (with the "class" attribute).
Example:
Code begin
<p style="color: #0000FF; font-size: 12pt">This is a paragraph with a defined style</p>
<p>And this is another text without style.</p>Code end
<p style="color: #0000FF; font-size: 12pt">This is a paragraph with a defined style</p>
<p>And this is another text without style.</p>Code end
lang (langcode)
Specifies the language of an element's content. The default value in "unknown".
When writing XHTML code the syntax "xml:lang" represents a preferred alternative in XHTML 1.0 and a replacement in XHTML 1.1 (e.g., xml:lang="en").
Example:
Code begin
<p lang="en">This is a paragraph in english.</p>
<p lang="es">Este es un párrafo en español.</p>Code end
<p lang="en">This is a paragraph in english.</p>
<p lang="es">Este es un párrafo en español.</p>Code end
dir
Specifies the text direction of the element's contents and attribute values, as well as tables directionality. It has two possible values that are case insensitive:
- RTL: Right to left.
- LTR: Left to right.
Code begin
<q lang="he" dir="rtl">...a Hebrew quotation...</q>Code end
<q lang="he" dir="rtl">...a Hebrew quotation...</q>Code end
align
This attribute have been deprecated
Specifies the horizontal alignment of its element. Possible values are (case-insensitive):
- left: Text is aligned to the left margin.
- center: Text is centered.
- right: Text is aligned to the right margin.
- justify: Text is justified to both margins.
Events
- onclick
- ondblclick
- onmousedown
- onmouseup
- onmouseover
- onmousemove
- onmouseout
- onkeypress
- onkeydown
- onkeyup
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
No comments:
Post a Comment