跨度和div [英] span and div

查看:84
本文介绍了跨度和div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我什么时候应该使用span?什么时候应该使用div?

解决方案

在帖子< news:3c ****** *******************@posting.google.c om>

DMJ说:

我什么时候应该使用span?什么时候应该使用div?



http://www.w3.org/TR/html401/struct/....html#edef-DIV


-

brucie

08 / December / 2003 07:42:37 pm kilo


< blockquote> brucie写道:

在帖子< news:3c ************************* @ posting.google。 c om>
DMJ说:

我应该何时使用span,何时应该使用div?


http://www.w3.org/TR/html401 /struct/....html#edef-DIV

哇...

不要打扰我,只要去看看w3c


我只是觉得这不是一个新闻组的目的,只是当他们有所谓的琐碎时,就会把人送走。问题。

对于span / div问题,我还没有看到一个非常清晰的教程

在哪里解释,我必须自己弄明白它们是什么

用于和他们感兴趣的是什么。


所以我按如下方式使用它们:

div用于构建概念上不同的信息(菜单vs

内容与插件...)

span用于突出显示某些其他文本中的文本或

分隔不同部分不能真正被视为列表的信息


当然有很多方法可以实现span& div,这取决于你能找到正确的方法吗?记住问题我真的吗?b $ b需要一个span / div吗?在我的结构中它意味着什么?


希望这有助于


" DMJ" <德***** @ angus.ac.uk> schrieb im Newsbeitrag

新闻:3c ************************* @ posting.google.co m ... < blockquote class =post_quotes>我什么时候应该使用span?什么时候应该使用div?




Span是一个内联元素,这意味着它是一个内联元素

元素的流程,通常是文本,包含在行尾。


Div是一个块元素,它应该被用作

元素或文本流的容器。


有些人使用div代替p标签和其他文本元素

(例如< div class =" title">)。我个人认为这是使用

内容相关元素的最简洁方式:

文本段落的
p

h1,h2 ...标题为

ul / ol,li为列表

table,td,tr for tables


- 将它们放入div中以定义宏结构

- 在其中使用跨度进行内联格式化


HTH

Markus


When should I use span and when should I use div??

解决方案

in post <news:3c*************************@posting.google.c om>
DMJ said:

When should I use span and when should I use div??



http://www.w3.org/TR/html401/struct/....html#edef-DIV

--
brucie
08/December/2003 07:42:37 pm kilo


brucie wrote:

in post <news:3c*************************@posting.google.c om>
DMJ said:

When should I use span and when should I use div??


http://www.w3.org/TR/html401/struct/....html#edef-DIV


wow...
"don''t bother me, just go and see the w3c"

i''m just feeling that this is not the purpose of a newsgroup to just
send people away when they have so-called "trivial" questions.
And for the span/div question i''ve not seen a really clear tutorial
where it is explained and i had to figure out by myself what they were
used for and what was their interest.

so i use them as follows :
div is for structuring conceptually different information (menu vs
content vs addons...)
span is for highlighting some text among some other text or for
separating differents parts of information that cannot really be
considered as lists

of course there are a lot of way to implement span & div and it''s up to
you to find the right way, having in mind the question "does i really
need a span/div here? what does it mean in my structure?"

hope this helps


"DMJ" <de*****@angus.ac.uk> schrieb im Newsbeitrag
news:3c*************************@posting.google.co m...

When should I use span and when should I use div??



Span is an inline element, which means that it makes part of a flow of
elements, usually text, that are wrapped at the end of the line.

Div is a block element, it is supposed to be used as a container for the
flow of elements or text.

Some people use div as a replacement for the p tag and other text elements
(like <div class="title">). I personally think it is the cleanest way to use
content-related elements the way they are meant:

p for text paragraphs
h1, h2... for headlines
ul/ol, li for lists
table, td, tr for tables

- put them into divs to define the macro structure
- use spans inside of them for inline formatting

HTH
Markus


这篇关于跨度和div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆