Difference between revisions of "CS46"

From Coder Merlin
m (Editorial review and minor corrections)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Whenever you see the div tag in HTML, think of it as the abbreviation of division. Because that’s precisely what it is! The div tag just defines a division or section of the HTML document. You can put anything you want inside this section, from a header to some body text.
== HTML div Tag ==


You know to use a div tag if your code for a website is divided into logical sections. For example, if a website was describing different kinds of fish, there would be div tags around each section describing one type of fish.
=== Introduction ===
Whenever you see the div tag in HTML, think of it as the abbreviation of ''division'', because that’s precisely what it is! The div tag just defines a division or section of the HTML document. You can put anything you want inside this section, from a header to some body text.


Although div tags don’t have any visual effect on the website itself, they are still beneficial. For example, they are important to use when wanting to implement a styles CSS file within that section. The div tag also makes it easier to read your code. That way, it is much easier for developers to view it.
You use a div tag to define a division or a section. For example, if a website is describing different kinds of fish, there would be div tags around each section for one type of fish.


To make the div tag, simply write "div" with a less than sign and a greater than sign before and after it.
Although div tags don't have any visual effect on the website itself, they are still beneficial. For example, they are important to use when wanting to implement a styles CSS file within that section. The div tag also makes it easier to read your code. That way, it is much easier for developers to view it.


To close the div tag, write: write "\div" with a less than sign and a greater than sign before and after it.
=== Example ===
To make the div tag, use this syntax:
<syntaxhighlight>
<div class="myDiv">
</syntaxhighlight>


Another way of making your code much more readable is by tabbing the code within the div tag. This can be done by highlighting all the code with the div tag and pressing the tab key. That way, all the code within each div tag can be visually distinct.
To close the div tag, type:
<syntaxhighlight>
</div>
</syntaxhighlight>
 
=== Conclusion ===
Another way of making your code much more readable is by indenting the code within the div tag. This can be done by highlighting all the code with the div tag and pressing the tab key. That way, all the code within each div tag is visually distinct.

Latest revision as of 19:49, 8 February 2023

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

HTML div Tag[edit]

Introduction[edit]

Whenever you see the div tag in HTML, think of it as the abbreviation of division, because that’s precisely what it is! The div tag just defines a division or section of the HTML document. You can put anything you want inside this section, from a header to some body text.

You use a div tag to define a division or a section. For example, if a website is describing different kinds of fish, there would be div tags around each section for one type of fish.

Although div tags don't have any visual effect on the website itself, they are still beneficial. For example, they are important to use when wanting to implement a styles CSS file within that section. The div tag also makes it easier to read your code. That way, it is much easier for developers to view it.

Example[edit]

To make the div tag, use this syntax:

<div class="myDiv">

To close the div tag, type:

</div>

Conclusion[edit]

Another way of making your code much more readable is by indenting the code within the div tag. This can be done by highlighting all the code with the div tag and pressing the tab key. That way, all the code within each div tag is visually distinct.