So my brother is home for the holidays, and he is trying to learn HTML & Javascript. I've had some success explaining to him many of the concepts related to this. Most of the tags are pretty self explanatory, but I've struggled with describing a div tag.
To be honest, I never really got a good description for myself, just through experience I know when to use one.
A good answer will not need to include the definition of "block element" or any other technical jargon, although you can assume some basic knowledge of some HTML tags
Definition and Usage The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute.
Div tag has both open(<div>) and closing (</div>) tag and it is mandatory to close the tag. The Div is the most usable tag in web development because it helps us to separate out data in the web page and we can create a particular section for particular data or function in the web pages.
The <div> tag is an empty container that is used to define a division or a section. It does not affect the content or layout and is used to group HTML elements to be styled with CSS or manipulated with scripts.
For some reason the purpose or logic around the <div> </div>
tags, made sense to me looking at cloth clips, and the reason it is because:
(<div> </div>)
<div>
alone can not work.I think the W3's specs are quite approachable:
The div element has no special meaning at all. It represents its children. It can be used with the class, lang, and title attributes to mark up semantics common to a group of consecutive elements.
Note: Authors are strongly encouraged to view the div element as an element of last resort, for when no other element is suitable. Use of more appropriate elements instead of the div element leads to better accessibility for readers and easier maintainability for authors.
The tag is nothing more than a container unit that encapsulates other page elements and divides the HTML document into sections. Web developers use elements to group together HTML elements and apply CSS styles to many elements at once. For instance, by wrapping a set of paragraph elements into a element, the developer can take advantage of CSS styles and apply a font to all paragraphs at once by applying a font style to the tag instead of coding the same style for each paragraph element.
Taken from http://www.tizag.com/htmlT/htmldiv.php
I think to be honest wikipedia proves a very simple explanation.
en.wikipedia.org/wiki/Div_tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With