I learn in my computer subject the usage of DIV and SPAN tags in HTML. The <span> and <div> tags are very useful when dealing with Cascading Style Sheets. People tend to use the two tags in a similar fashion, but they serve different purposes.
The <div> tag in XHTML is a tag that defines logical divisions within the content of a page. What this means is that a <div> tag defines sections of a Web page to make it easier to manage, style, and manipulate. You can use the <div> tag when you want to center a block of content or position a content, block on the page. The <div> tag is a very powerful tool for Web developers. It acts a lot like a paragraph tag, but it divides the page up into larger sections. The <div> also gives you the chance to define the style of whole sections of HTML. You could define a section of your page as a call out and give that section a different style from the surrounding text.
The primary attributes of the <div> tag are:
- style
- class
- id
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 the enclosed 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 <div> tag acts includes a paragraph break, because it is defining a logical division in the document. The <span> tag simply tells the browser to apply the style rules to whatever is within the <span>. Use <span> when you want to change the style of elements without placing them in a new block-level element in the document. For example, if you had a Level 3 Heading (<h3>) that you wanted the second word to be red, you could surround that word with
<span style="color:red">2ndWord</span>
and it would still be a part of the <h3> tag, just red.
The <span> tag has no required attributes, but the three that are the most useful are:
- style
- class
- id
I have learn that when i use the div and span tags my html become more beautiful. They help my html to become attractive. When I use them I'm sure that my html will become standard in web page.
Walang komento:
Mag-post ng isang Komento