浏览器如何解析html文档? [英] How does a browser parse an html document?

查看:84
本文介绍了浏览器如何解析html文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我再来一次。试着学习更多:>)我希望我的术语

正确。


浏览器如何解析(正确的术语?)HTML文档。我肯定

,每个浏览器都会有所不同。他们只是简单地从上到下和从左到右阅读文件并按照他们遇到的顺序显示

元素吗?或者,他们是否给某些类型的内容优先

?例如,浏览器首先显示文本,然后显示所有图像,然后显示所有Javascripts等等吗?

比方说,我有一个大图像(让'比方说1MB)。图片是我的段落左边浮动的
,所以这是我的代码:


< img src =" image.jpg" style =" float:left">

< p> blah blah blah,yadda yadda yadda< / p>


浏览器是否会按顺序加载这些,所以我必须等待1MB才能获得
要加载的图像,然后我会看到文字吗?


我问,因为有些时候我无法分辨。当然,一个网站的本地副本

总是很快 - 它在你的硬盘上。但是我会一遍又一遍地加载相同的页面(在重新加载之间清空缓存
)并且它似乎以不同的顺序加载每个
时间。有时候我会先看文字,有时候我会先看到图片。


另外,知道这一点也可以帮助我优化页面加载速度更快。


感谢所有回复的人。我真的很开心,我很乐意学习。我甚至可以去当地的大学看看是否有任何可用的课程:>)


Viken K.

推荐答案

Viken Karaguesian写道:
Viken Karaguesian wrote:
感谢所有回复的人。我真的很开心,我很享受学习。我甚至可以去当地一所大学看看是否有可用的课程:>)
Thanks to all who reply. I''m really having fun with this and am
enjoying learning. I may even go to a local university to see if
there are any classes available :>)




如果你错过了alt的主题。 www.webmaster ,读取网页设计教师的内容;几天前:


< http://groups.google.com/group/alt.www.webmaster/browse_frm/thread/9260ab7b04c2a812/2c3e5a604de2f532?tvc = 1& q =网络+设计+老师+ alt.w ww.webmaster& hl = en#2c3e5a604de2f532>


小心学校。通过潜伏和闲逛这些新闻组,你可能会学到更多有用的东西。记得要问

智能问题。 < g>


-

-bts

-警告:我为草坪鹿刹车



If you missed the thread on alt.www.webmaster about Uni classes, have a
read of "Web Design Teachers" from a few days ago:

<http://groups.google.com/group/alt.www.webmaster/browse_frm/thread/9260ab7b04c2a812/2c3e5a604de2f532?tvc=1&q=web+design+teachers+alt.w ww.webmaster&hl=en#2c3e5a604de2f532>

Tread carefully with the school. You''re likely to learn much more useful
stuff by lurking and hanging around these newsgroups. Remember to ask
intelligent questions. <g>

--
-bts
-Warning: I brake for lawn deer


Viken Karaguesian写道:
Viken Karaguesian wrote:
浏览器如何解析(正确的术语?)HTML文档。我确定每个浏览器都会有所不同。他们只是简单地从上到下和从左到右阅读文档,只是按照他们遇到的顺序显示
元素?或者,他们是否优先考虑某些类型的内容?例如,浏览器首先显示文本,然后显示所有图像,然后显示所有Javascripts等等吗?例如,说我有一个大图像(让我们说1MB)。图像在我的段落左侧浮动,所以这是我的代码:

< img src =" image.jpg" style =" float:left">
< p> blah blah blah,yadda yadda yadda< / p>

浏览器是否会按顺序加载这些,所以我必须等待1MB图像加载,然后我才会d看文字?


图像将在后台下载,而其余的

文档被加载/解析(其他外部文件如
也会发生同样的情况)
stylesheet,applets ...但不是JavaScript文件AFAIK)。如果图像有

WIDTH和HEIGHT属性,那么浏览器可以保留页面上适当数量的空间,并且以下文本可以流动
,即使在图像显示之前。如果没有WIDTH / HEIGHT,

浏览器有时会渲染以下文本,好像没有图像

,然后在知道图像尺寸时重新计算布局。 />
另外,知道这也可以帮助我优化页面以加快加载速度。
How does a browser parse (correct term?) an HTML document. I''m sure
that every browser does it a little differently. Do they simply just
read a document top-to-bottom and left-to-right and just display
elements in the order in which they encounter them? Or, do they give
priority to certain types of content? For instance, would a browser
display text first, then all the images, then all Javascripts, etc?
Say, for example, I had a large image (let''s say 1MB). The image is
floated left of my paragraph, so this is my code:

<img src="image.jpg" style="float: left">
<p> blah blah blah, yadda yadda yadda </p>

Would a browser just load these in order, so I would have to wait for
the 1MB image to load, then I''d see the text?
The image will be downloaded in the background while the rest of the
document is loaded/parsed (same happends for other external files like
stylesheet, applets... but not JavaScript files AFAIK). If there would be
WIDTH and HEIGHT attributes for the image, then the browser could reserve
the right amount of space on the page and the following text can flow
around it, even before the image is displayed. Without WIDTH/HEIGHT the
browser will sometimes render the following text as if there is no image
and then recalculate the layout when it knows the dimensions of the image.
Also, knowing this would also help me optimize pages to load faster.




如果你在图像中指定WIDTH / HEIGHT,那么其他的东西就在您的页面

在浏览器重新计算布局时不会跳。速度

改进可能很小,但它看起来更顺畅。


-

Benjamin Niemann

电子邮件:粉红色at odahoda dot de

WWW: http:/ /www.odahoda.de/


>如果您错过了关于Uni课程的alt。 www.webmaster 上的帖子,请
> If you missed the thread on alt.www.webmaster about Uni classes, have a
阅读网页设计教师几天前:

< http://groups.google.com/group/alt.www.webmaster/browse_frm/thread/9260ab7b04c2a812/2c3e5a604de2f532?tvc = 1& q = web + design + teachers + alt.w ww.webmaster& hl = en#2c3e5a604de2f532>
read of "Web Design Teachers" from a few days ago:

<http://groups.google.com/group/alt.www.webmaster/browse_frm/thread/9260ab7b04c2a812/2c3e5a604de2f532?tvc=1&q=web+design+teachers+alt.w ww.webmaster&hl=en#2c3e5a604de2f532>




呀!哇...我不知所措。


Viken K.



Yikes! Wow...I''m at a loss for words.

Viken K.


这篇关于浏览器如何解析html文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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