Call Us+374 60 52 55 00

The SPAN and DIV Tags

The SPAN and DIV Tags

People tend to use the two tags in a similar fashion, but they serve for completely different purposes.
<div>
The <div> tag defines logical divisions in your Web page. It acts a lot like a <p> tag, but it divides the page up into larger sections. <div> gives you the chance to define the style of whole sections of HTML. It also gives you the ability to name certain sections of your pages so that you can affect them with Css or Dynamic HTML. One thing to keep in mind when using the <div> tag is that <div> breaks paragraphs and while you can have paragraphs within a <div> you can't have a <div> inside a paragraph.
The primary attributes of the <div> tag are:
•style
•class
•id
Even if you don't use Css or DHTML, you should get into the habit of using the <div> tag. This will give you more flexibility. Also, you can use the id and name attributes to name your sections so that your Web pages are well formed (always use the name attribute with the id attribute and give them the same contents).

<span>
The <span> tag has very similar properties to the <div> tag, in that it changes the style of the text it encloses. But without any style attributes, the <span> tag won't change items at all.
The primary difference between the <span> and <div> tags is that <span> doesn't do any formatting of it's own.
The <span> tag has no required attributes, but the three that are the most useful are:
•style
•class
•id
Use <span> when you want to change the style of elements without placing them in a new block-level element in the page.


Back

Request form

Name: 
Email: 
Phone: 
Type of project: 
 

Contact Info

Contact Info
+374 60 52 55 00
+374 55 52 55 00
info@impressionwebstudio.com
2nd floor, 12a Vagharshyan street,
0012 Yerevan, Armenia