For some time, I found that many people don’t know how to use XHTML. Not only ordinary beginners, but some programmers are not very clear about how to write XHTML. Here I am going to summarize some common application problems, which can also enable everyone to form a tacit understanding in communication and cooperation.
There are many tags in XHTML, but there are only a few that are often used, and you just need to master these. Let's list them one by one: div,p,span,ul,li,dl,dt,dd,a,img,h,strong,em
div In my mind, I always think of it as a bottle or box, and I feel it is quite hard. This div has no characteristic meaning and can be used in many places, which means it can install different things. His correct way of writing is that there must be a seal. Everyone uses it for layout and also for storing articles to form paragraphs. In fact, this approach is not very good, because as a segment of an article, there is naturally a specific label to use. That is the <p></p> tag to be discussed below, but DIV is used to cover all paragraphs as a whole. This is very practical.
p This is a tag with specific semantics that represents paragraphs and is used to distinguish paragraphs. In most browsers, there is basically an up and down margin for P. However, there is no line-head indentation because line-head indentation is only a way to represent paragraphs but is not necessarily or necessary. Therefore, when using P tags, you can set the line indentation for P. I recommend not using P outside the article, because P has certain semantics, and it may not be appropriate if used in other places. The correct way to write it is <p></p>
span This is also a very commonly used tag. This tag can be said to be very similar to div and has no specific meaning. It is just that it is a cascading element, not a block-level element. I have always regarded it as a bag. It does not have its own width and height like a box. Its width and height can only depend on the amount of content, so it is very similar to a bag. This tag is exactly complementary to the div.
ul,li This is a list. In the list, in addition to UL, there are OLs, but I think OL is a bit useless. Because UL can also have the OL number sorting effect through CSS definition. So I generally don’t recommend using OL, just have UL. UL is block-level, and its child li is also block-level tag. The correct way to write it is <ul><li></li></ul> The LI tag is wrapped by the UL tag. There can be countless LI tags in the UL tag, and the LI tag cannot be used independently. In addition, the LI label must be sealed, which is not only a matter of aesthetics, but also very beneficial for later maintenance. Many programmers don’t like to ban this LI. The purpose of UL lists is mainly to list one-dimensional, same type of data. For example, some regulations on the menu, listing in the article, etc. There is a special form in the list that is different from UL. That's the DL below
dl,dt,dd This is a very special combination of three tags. Here DT refers to the title, DD refers to the content. DL is the container for their courses. The correct way to write it is <dl><dt></dt><dd></dd></dl> There can be many groups of DT and DD in DL. When many groups appear, try to match one DT with one DD. If there is a lot of content in DD, you can add a P tag to DD to use it. DL list is a very good list form and can be used more.
a This means that a link is a specific attribute and the most magical tag in the web page. It makes countless web pages connected. The correct way to write it is: <a href= title=></a> where href represents the target address, and TITLE is the mouse hover prompt text, which is optional. But it must be more profit than nothing.
img This is an image tag, and it is also a tag with a specific attribute. The normal way to write it is: <img src= alt= title=/> Here src is the target address, ALT and TITLE are replacement text, ALT is IE-specific, and TITLE is common to other browsers. But remember that there must be a backslash line behind it.
H This is a series of tags, from H1 to H6, there are six in total. Some people say it is too few, some people say it is just right, and some people say it is not used so much. Anyway, I think it's almost the same. The correct way to write it is: <h></h> is mainly used to store titles, and some friends also use it for other purposes. I personally think that this label should be more at ease, so let it serve as the title. It is best not to have anything that contains each other between these six labels.
strong means focus, it has semantics and has a simple function. As for the sample work, whether to highlight the boldness or use color to indicate the emphasis, it is all your choice. The correct way to write it is <strong></strong>
em This is very similar to strong, which means emphasis. The default value of a general browser is italic. Use the same way as strong. The writing method is: <em></em>
The form is not mentioned here, because the form has basically no changes and nothing to say in particular.