问题描述
好吧,我知道
是没有语义的.问题在于,当存在诸如以下的段落时:
Well, I know that
is unsemantic. The problem is that when there are paragraphs such as:
好吧,我只是在开玩笑. Lorem ipsum dolor坐在amet,consectetur 忠实的精英.菱形在菱形. Nulla aliquam turpis ac magna scelerisque vel eleifend libero malesuada . leo et elit ultricies id suscipit leo ornare. Vestibulum mi dioo, 不带贝母的植物,无毛的雌蕊. Nunc enim 擦除,其他车辆.
Ok, I'm just kidding. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Rhoncus at magna. Nulla aliquam turpis ac magna scelerisque vel eleifend libero malesuada.
Quisque facilisis leo et elit ultricies id suscipit leo ornare. Vestibulum mi odio, facilisis non fringilla vitae, imperdiet egestas mauris. Nunc enim erat, vehicula vel malesuada nec.
如您所见,有两个段落.它们两个都在中间由<br>
标记进行换行.出于语义上的原因,不使用此标记怎么办?
As you can see there are two paragraphs. Both they have a line break in the middle done by a <br>
tag. How can i do it without the use of this tag for semantic's sake?
注意:插入的粗体"malesuada"可帮助您轻松识别第二个换行符.
Note: The bold "malesuada" was inserted to help you identify the second linebreak easily.
推荐答案
首先,换行符旨在用于必须在文本流中(例如在一首诗中)出现换行符的情况.
First, line breaks are intended to be used in situations where the break must occur within the flow of text, such as in a poem.
像这样的文本标记方法通常被接受为段落,这些段落是块级的,因此总是创建新行,并在它们之间设置边距.在这里,您有两种段落样式,一种需要空间,一种不需要空间.您可能会有两种不同的段落样式(我在这里仅说明了垂直边距-水平边距设置为0).
The generally accepted way to markup text like this is as paragraphs, which are block level and therefore always create a new line, and to set the margins between them. Here you have two paragraph styles, one that requires space and one that does not. You could have two different styles of paragraph like this (and I just illustrate the vertical margins here - the horizontal ones are set to 0).
p {margin:.1em 0;}
p.special {margin:0;}
然后只需将特殊"类添加到没有空格的段落中即可.请注意,垂直边距将折叠,因此每个段落之间只有1em的空间.
Then just add the class "special" to the paragraphs without space. Note the vertical margins will collapse so you will only get 1em of space between each paragraph.
我最大的问题是设计问题:为什么要这样组织段落?为什么不仅要在整个段落中使用标准的段落间距,还可能需要使用标题来对段落集进行分组?您正在做的事情是非常常规的,这就是为什么您在寻找要使用的正确HTML元素时遇到问题的原因. hth,查尔斯
My bigger question though is a design one: why do you want to organize your paragraphs like this? Why not just have a standard paragraph spacing throughout and perhaps using headings to group the sets of paragraphs? What you are doing is rather unconventional, which is why you are running into problems finding the right HTML elements to use. hth, charles
这篇关于< br>标签语义替代用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!