사용시기
대
태그 <p>...</p>
대신 다른 것을 사용해야 할 때에 대한 평결은 무엇입니까 <br />
? 이런 종류의 모범 사례는 무엇입니까?
이 질문을 둘러 보았지만 대부분의 글이 약간 오래된 것 같아서이 주제에 대한 의견이 그 이후로 발전했는지 확실하지 않습니다.
편집 : 질문을 명확히하기 위해 여기에 내가 다루는 상황이 있습니다. 다음 콘텐츠에 <br>
's 또는 <p>
's를 사용 하시겠습니까 (홈페이지의 div에 포함되어 있다고 상상해보세요).
홈페이지에 오신 것을 환영합니다.
우리 물건을 확인하십시오.
정말 그래야합니다.
이제이 줄은 기술적으로 '단락'이 아닙니다. 따라서 <p>
태그 의 전체 블록 <br>
을 사이에 's' 로 둘러 싸서 마크 업 하시겠습니까 , 아니면 <p>
각 줄에 별도의 ' 를 사용 하시겠습니까?
그들은 두 가지 다른 기능을 제공합니다.
<p>
(paragraph)는 텍스트를 보관하는 데 사용되는 블록 요소입니다. 요소 <br />
내에서 줄 바꿈을 강제하는 데 사용됩니다 <p>
.
예
<p>Suspendisse sodales odio in felis sagittis hendrerit. Donec tempus laoreet
est bibendum sollicitudin. Etiam tristique convallis<br />rutrum. Phasellus
id mi neque. Vivamus gravida aliquam condimentum.</p>
결과
felis sagittis hendrerit의 Suspendisse sodales odio. Donec tempus laoreet est bibendum sollicitudin. Etiam tristique convallis
rutrum. Phasellus id mi neque. Vivamus gravida aliquam condimentum.
최신 정보
새로운 요구 사항에 따라 개인적으로 <p>
공간을 확보하고 스타일링을 허용합니다. 앞으로 이러한 부분 중 하나를 스타일링하려면 블록 수준에서하는 것이 훨씬 더 쉬울 것입니다.
<p>Welcome to the home page.</p>
<p style="border: 1px solid #00ff00;">Check out our stuff.</p>
<p>You really should.</p>
<p>
두 가지 정보 스트림을 별도의 생각으로 분리해야 할 때 태그 를 사용하려고합니다 .
<p> Now is the time for all good men to come to the aid of their country. </p>
<p>The quick brown fox jumped over the lazy sleeping dog.</p>
<br/>
태그는 웹 페이지의 텍스트 흐름 내에서 강제 줄 바꿈으로 사용됩니다. 시와 같이 텍스트가 다음 줄에 계속되기를 원할 때 사용하십시오.
<p> Now is the time for all good men to come to the aid of their country. <br/>
The quick brown fox jumped over the lazy sleeping dog. </p>
지금까지 대부분의 답변이 훌륭 했으므로이 스레드의 질문에 답할 때 에티켓 규칙을 위반할 수 있습니다.하지만이 주장에 접근하는 방법은 다음과 같습니다.
'p'는 텍스트를 보관하는 데 사용되는 요소이고 'br'태그는 텍스트를 나누는 데 사용된다는 데 동의하지만, 많은 경우에 실제 줄 간격이있는 텍스트의 '블록'을 조작하고 싶을 수 있습니다.
예 :
[내 텍스트 블록]
Hello World!
-------- 이것은 빈 줄입니다 .------
당신은 인생으로 가득 차 있습니다!
[/ 내 텍스트 블록]
이제 많은 사람들이 'div'에 두 개의 'p'요소를 배치 한 다음 해당 'div'를 조작 할 수 있다고 주장하지만, 이것이 더 많은 시간이 소요된다고 생각합니다 (일명 게으르다). 'br'방법-그 'p'만 조작 할 수 있습니다.
내 비 정통적인 방법의 문제는 선 높이에 특정 스타일이 적용되면 이중 'br'과 'p'에 의해 생성 된 선 공간간에 눈에 띄는 차이가 분명히 있다는 것입니다.
따라야 할 기술을 결정할 때 다음을 고려하십시오.
- 코드 가독성
- 모범 사례
- 시각
- 코드의 나머지 부분에 대한 단축키의 영향
<p>
두 단락을 분리하고자 할 때 사용해야합니다 . Wikipedia에서 :
A paragraph (from the Greek paragraphos, "to write beside" or "written beside") is a self-contained unit of a discourse in writing dealing with a particular point or idea.
Use the <br>
tag when you want to force a new line inside your paragraphs.
I wouldn't use <p>
unless you intend to put content within it. Of course, this is merely an opinion (as I assume most answers will be).
However, it may be easier to style a <p>
tag (there are more options at least) which may lend itself to be used more often. My only problem is that this is not very easy to read (when reading code) and I feel like those styles could be applied elsewhere (possibly to the tags that would surround the <p>
tag.
Also, as other have stated, a <br />
tag should be used to separate content within a block element (such as the <p>
tag). If you are using the following:
<p class="a">some content...</p>
<p class="break"></p>
<p class="b">some other content...</p>
Then I would argue that you should use styles on one or both of the tags surrounding the p.break
tag to do any spacing that is required.
The p
tag is a block level element, and is mainly used to add content, whereas the br
tag is used to force a line-break within the element. That is, if you're going to follow semantics. A lot of people are doing that these days to add specific meaning to tags and whatnot. I hope that helps. Good luck, though. =)
참고URL : https://stackoverflow.com/questions/13688158/when-to-use-p-vs-br
'Development Tip' 카테고리의 다른 글
ggplot에 대한 curve ()와 동일 (0) | 2020.11.18 |
---|---|
사전에서 defaultdict를 구성하는 방법은 무엇입니까? (0) | 2020.11.18 |
SQL Server에서 SQL 삽입으로 작은 따옴표를 벗어나는 위생을 어떻게 방지 할 수 있습니까? (0) | 2020.11.18 |
git commit의 --date 매개 변수의 형식은 무엇입니까? (0) | 2020.11.18 |
이 C 프로그램은 두 가지 주요 기능으로 어떻게 컴파일되고 실행됩니까? (0) | 2020.11.18 |