i'll never know if i dont ask.. what is span actually? p and span are same? why should i use span over p if they are same?
what is span and p?
| yo.hassan wrote: |
| i'll never know if i dont ask.. what is span actually? p and span are same? why should i use span over p if they are same? |
span is an inline element and p is block-level. If you don't know what I'm talking about, head over to google, it's a good idea to be familiar with the basics of html.
P is for paragraphs. It's just like div in that it is a basic block-level element, but it has some extra margin settings.
The <span> tag can be used to change the look of text within a paragraph. Here are two examples.
This code...
..will look like this when rendered in a browser.
-------------------
This is a paragraph of text with
this particular text
enclosed within a nested <p> tag.
-------------------
Whereas, this code...
..will look like this when rendered in a browser.
-------------------
This is a paragraph of text with this particular text enclosed within a nested <span> tag.
-------------------
This code...
| Code: |
|
<p>This is a paragraph of text with <p style="color:#f00;">this particular text</p> enclosed within a nested <p> tag.</p> |
..will look like this when rendered in a browser.
-------------------
This is a paragraph of text with
this particular text
enclosed within a nested <p> tag.
-------------------
Whereas, this code...
| Code: |
|
<p>This is a paragraph of text with <span style="color:#f00;">this particular text</span> enclosed within a nested <span> tag.</p> |
..will look like this when rendered in a browser.
-------------------
This is a paragraph of text with this particular text enclosed within a nested <span> tag.
-------------------
for god sake search the forums before posting questions. This has been asked and answered numerous many many times here. In case you are beginning HTML, head over to w3schools.com if you haven't already.
Everything said up to now is all true however much detail is still lacking.
Within most block-level elements, block-level elements are permitted. However all block-level elements can contain inline elements. The divider(<div>) element is a generic block-level element and can contain both inline and block-level elements. The span(<span>) element is a generic inline element. An inline element cannot contain a block-level element unless specified with CSS however such coding is discouraged by the w3c and will not pass the validator. The paragraph(<p>) element is block-level yet has a functionality which forbids block-level elements from appearing within it. The paragraph element can be replaced by a combination of <div><span>...</span></div>.
Within most block-level elements, block-level elements are permitted. However all block-level elements can contain inline elements. The divider(<div>) element is a generic block-level element and can contain both inline and block-level elements. The span(<span>) element is a generic inline element. An inline element cannot contain a block-level element unless specified with CSS however such coding is discouraged by the w3c and will not pass the validator. The paragraph(<p>) element is block-level yet has a functionality which forbids block-level elements from appearing within it. The paragraph element can be replaced by a combination of <div><span>...</span></div>.
| yo.hassan wrote: |
| i'll never know if i dont ask.. what is span actually? p and span are same? why should i use span over p if they are same? |
Googling is the fastest way to find it out!
