简体   繁体   中英

HTML5 <p> Tags function

Hello Im New in Coding so im just learned about HTML5 and CSS3 and in my Course i found something that makes me confused

So when i see in my course that use HTMl5 you can make Text appearing without using p tag so, whats the different about using p tag and without p tag?

p标签代表段落,因此,如果使用p标签,您将让浏览器知道这是一个段落,这对搜索引擎也有好处。您可以使用CSS设置文字样式

p tags have some properties built in a browser for example:

p {
    display: block;
    -webkit-margin-before: 1em;
    -webkit-margin-after: 1em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
}

They are block elements and have some margin around them. You can display some text without the p tag, but that wouldn't get the styling of ap tag. And you mainly want to style all your p tags with certain properties to make the site design consistent. For example, you want to set the line-height of ap tag and the font-size.

If you just display the text like:

<body>
  Hello World!
</body>

Hello World would get the styling from the body tag.

Well, first of all you need the tags in order to be able to style your text. Besides that, it is a very bad and uncommon practice to leave text outside of tags. It just doesn't fit the norms and standards of HTML & CSS. Besides that, tags are important for your SEO (Search Engine Optimization) ranking, which means that eg Google needs tags like <p> to understand your site and rank it accordingly to the search query.

Here is a link, which may help you understand <p> tags better.

you can also use div tag for showing your text

your text

When you work in technologies like HTML5 and CSS3 you need to know that all the text that you write in your .html file is going to show on your page, since it is interpreted as a text string in HTML5 .

You have lots of tags with which you can show text. When you use <p> some text</ p> , this indicates that the text within it will contain a Paragraph .

If your text is not inside a label, it's a bad practice and you will not have control of it in the future with the help of your .css file. (That will be your file to define the styles of your tags used in your .html file)

As I mentioned before, there are many labels to contain your texts from titles to buttons (an example of titles we have the tags <h1>, <h2> ... <h6> where h1 will be a title, h2 a subtitle and so on)

I recommend this website that helps me a lot when it comes to giving my classes since it explains from 0 many of the web technologies and there you can find much more on the subject of tags. regards... https://www.w3schools.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM