HTML text: do I need specific tags to use text?
What I want to do is
<div>some text <span>different text</span> more text </div>
I wasn't sure if I needed one of <a><p><h1>
tags to use text or if I could simply just write it with just div.
Does it affect proper markup or SEO?
Also in cases where I am using the header tags <h1><h2>
, etc.
How many can I go up to? Such as <h7>
+?
And just wondering, can I use the same heading as many times as necessary right?
As in, if I declare &l开发者_开发知识库t;h1>
to have some font declarations can I use it multiple times on a page?
Divs will be fine, but they are not particularly descriptive, neither is span.
Allways try to use the tag that best describes the content. eg. use
for a paragraph of text, for some important information etc...
Try to reserve for things like layout, a thing that carries no real information.
Just text without any formatting, without any position, without anything, just text (which will look very bad and completely NOT USER friendly, like this answer!) divs are okay.
You may even just write the text. There is no need to put divs if there is no need of formatting of any kind.
DIV
and SPAN
are used for grouping. You should still have semantic markup like P
for paragraphs or H1
through H6
(that's as high as it goes) for headings. Just worry about semantics and well-formed documents; SEO will take care of itself if you do those two things (and have useful content of course).
People use the A
(anchor) tag a lot for different reasons. Mainly it's because HTML stands for HyperText Markup Language—the "hyper" connotes the incorporation of additional content/media/features compared to plain text documents. One of the biggest distinguishing characteristics of hypertext documents is the ability for one document to link to another using hyperlinks—this are created with the A
tag.
The A
tag can also be used to link to different sections of the same document or another document. These points are specified by the A
tag as well, like so:
<p><a name="top">Hello World</a></p>
<p>Blah, blah, blah.</p>
<div><a href="#top">Back to top</a></div>
Additionally, anchors can also be created using the ID
attribute, which can be used in almost any tag:
<h2 id="ToC">Table of Contents</h2>
...
<p>View the <a href="#ToC">Table of Contents</a>
to see all sections of this guide.</p>
精彩评论