Home  >  Article  >  Web Front-end  >  How to set the height of label tag in html? Introduction to how to use label tags

How to set the height of label tag in html? Introduction to how to use label tags

寻∝梦
寻∝梦Original
2018-09-04 16:09:217640browse

This article mainly introduces how to set the height of the label tag in HTML. There is also an introduction to how to use HTML label tags. Let's take a look at this article about html label tags

First of all, let's take a look at how to set the height of label tags in html:

The label 2e1cf0710519d5598b1f0f14c36ba6748c1ecd4bb896b2264e0711597d40766c in HTML defines text labels for form elements. 2e1cf0710519d5598b1f0f14c36ba674 is an inline element. There are no line breaks before and after the element, and the height cannot be set.

If you want to set the height, you need to set the display attribute of 2e1cf0710519d5598b1f0f14c36ba674. The default attribute is inline. At this time, the element will be displayed as an inline element. The element does not have a line break. You only need to add it after inline. block, that is, display:inline-block. At this time 2e1cf0710519d5598b1f0f14c36ba674 is changed to a block element, and the height of 2e1cf0710519d5598b1f0f14c36ba674 can now be modified.

The conditions given in this picture need to set the width of 2e1cf0710519d5598b1f0f14c36ba674 to 80px. At this time, 2e1cf0710519d5598b1f0f14c36ba674 is an inline element and the height cannot be modified directly. At this time, you only need to change the display attribute in the code. It's OK:

<label  class=&#39; p1&#39; style=&#39;dispaly: inline-block&#39;>姓名</label>

Then set

<style>
.p1{
width:80px;
}
</style>

in the head so that the width is adjusted.

Now let’s talk about how to use the html label label:

The label label is a label used as a "label" in the form of the html code. Do not I was confused by this sentence. This "label" is not that label. Its function is to add words before the form to describe the form.

In the ff9c23ada1bcecdd1a0fb5d5a0f18437f5a47148e367a6035fd7a2faa965022e label, you will find that if there is no text between any labels, the form will be displayed incorrectly. At this time, this label is introduced Label, the usage method is as follows:

<form id="dreamduform" action="http://www.php.cn/dreamdu.php" method="post">
<label for="contactus">PHP中文网</label>
<textarea cols="50" rows="10" id="contactus">
这里是PHP中文网
</textarea>
</form>

In the above example, the function of the for attribute is the id of the form described by this label. It seems that this attribute can be valued in js and the form id can be obtained. That's what I understand, but I haven't actually tested it.

The above is all about setting the height and usage of html label tags (if you want to learn more programming knowledge, come to the PHP Chinese website. There are more courses and better teachers for you. Answer), if you have any questions, you can leave a message below.

【Editor’s Recommendation】

How to write html space code? Summary of the expression of html space code

How to wrap the html code tag? This article gives you a thorough understanding of the use of code phrases

The above is the detailed content of How to set the height of label tag in html? Introduction to how to use label tags. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn