web开发面试_如何处理您的Web开发人员面试问答:文档类型有什么作用?

web开发面试

by Zuzana K

由Zuzana K

如何处理您的Web开发人员面试问答:文档类型有什么作用? (How to tackle your Web developer interview Q&A: what does a doctype do?)

One part of the interview process for a web developer position probably involves answering some questions. Yes, we are not only expected to do the web stuff, but we are also expected to know the web stuff.

Web开发人员职位的面试过程的一部分可能涉及回答一些问题。 是的,我们不仅需要做网络工作,而且我们也应该了解网络工作。

I am very capable of writing an HTML document, using semantic tags, and following the best web standards, but there are things I never thought of learning.

我非常有能力使用语义标记编写HTML文档,并遵循最佳的Web标准,但是有些事情我从未想过要学习。

I recently received a list of web developer interview questions, and when I first glanced at the list, my heart almost stopped.

最近,我收到了一份有关Web开发人员面试问题的列表,当我第一次浏览该列表时,我的心几乎停了下来。

  • What does a doctype do?

    doctype有什么作用?
  • Are there any problems with serving pages as application/xhtml+xml?

    将页面用作application / xhtml + xml是否有任何问题?
  • What’s the difference between feature detection, feature inference, and using the UA string?

    特征检测,特征推断和使用UA字符串之间有什么区别?

Well, in all honesty, I couldn’t answer most of the questions.

好吧,老实说,我不能回答大多数问题。

I guess this is where a CS degree could come in handy.

我想这是CS学位派上用场的地方。

But, as a self-taught developer, I focused on doing, rather than knowing. Since I am looking for a job myself, however, I thought it might be wise to prepare for a web developer interview and answer some of these questions.

但是,作为一个自学成才的开发人员,我专注于做而不是知道。 但是,由于我自己正在寻找工作,所以我认为为Web开发人员面试做准备并回答其中的一些问题可能是明智的。

So in the next I-don’t-know-how-many posts, I will take a question from a web developer interview (that has been very graciously provided by Rose from the Verify recruitment agency in Dublin, Ireland), and answer it to the best of my ability.

因此,在接下来的“我不知道如何做”的帖子中,我将从网络开发人员访谈中提问(该问题由爱尔兰都柏林的Verify招聘机构的Rose非常慷慨地提供),并回答了尽我所能

I am going to tackle some HTML, some CSS, and some JavaScript questions.

我将解决一些HTML,一些CSS和一些JavaScript问题。

The answers will not be exhaustive, but they will hopefully give you and me a good head start, should we want to dig a little bit deeper.

答案虽然并不详尽,但是如果我们想更深入一点,它们有望为您和我提供一个良好的开端。

问题:<doctype>有什么作用? (Question: What does a <doctype> do?)

Doctype is the abbreviation for the “document type.” Duh, right? I mean, who would have thought?

Doctype是“文档类型”的缩写。 h,对不对? 我的意思是,谁会想到的?

But seriously, why do we need to specify the doctype when we save the document as an HTML file, which, surely, means that it is an HTML document? The thing is, you also need a <!doctype html> for a ‘.php’ page that includes HTML markup.

但是,认真地讲,为什么在将文档另存为HTML文件时需要指定doctype,这肯定意味着它是HTML文档? 事实是,对于包含HTML标记的'.php'页面,您还需要一个<!doctype html>。

This is where it gets confusing. So let’s unpack it a little bit.

这就是令人困惑的地方。 因此,让我们对其进行一些包装。

Doctype declaration tells the browser what kind of document to expect: HTML5, HTML4.0x, XHTML1.0 (Strict, Transitional or Frameset), XHTML1.1, and others.

Doctype声明告诉浏览器期望什么样的文档:HTML5,HTML4.0x,XHTML1.0(严格,过渡或框架集),XHTML1.1

But why is it required?

但是为什么要这样做呢?

For legacy reasons.

由于遗留原因。

In the early days of the Internet, two main browsers were competing against one another. Netscape Navigator and Internet Explorer. They kept coming up with new features that were often incompatible with the other, already existing features or other browsers.

在互联网的早期,两种主要的浏览器相互竞争。 Netscape Navigator和Internet Explorer。 他们不断提出新功能,这些功能通常与其他现有功能或其他浏览器不兼容。

It was a difficult time for the developers (let’s all take a minute and count our blessings).

对于开发人员而言,这是一段艰难的时期(让我们花一分钟时间并指望我们的祝福)。

So the founder of the World Wide Web, Sir Tim Berners-Lee, founded the World Wide Web Consortium (W3C) to standardize the protocols and technologies used to build the web and to make life easier for developers and users alike.

因此,万维网的创始人Tim Berners-Lee爵士成立了万维网联盟 (W3C),以标准化用于构建Web的协议和技术,并使开发人员和用户的生活更加轻松。

The new protocols were great for the new browsers and implementations, but they would totally break the existing sites.

新协议对于新的浏览器和实现非常有用,但是它们将完全破坏现有站点。

Enter Document Type Definitions (DTDs).

输入文档类型定义(DTD)。

DTDs tell the parser how to translate the code into what you see on the screen so that the look is uniform across different browsers.

DTD告诉解析器如何将代码转换为您在屏幕上看到的内容,从而使不同浏览器的外观保持一致。

To render a HTML4.01 document, use this code at the very top of your document:

要呈现HTML4.01文档,请在文档的顶部使用以下代码:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

To render a HTML5 document, include this code instead:

要呈现HTML5文档,请改为包含以下代码:

<!doctype html>

HTML5 is, admittedly, much easier to declare.

诚然,HTML5更容易声明。

Using the doctype declaration is a requirement placed upon us by W3C; without it, the HTML validators won’t work (because they won’t know what standard to check your code against) and the browser might render the document in a quirks mode.

W3C要求使用doctype声明; 没有它, HTML验证程序将无法工作(因为他们将不知道要使用哪种标准检查您的代码),并且浏览器可能会以古怪的方式呈现文档。

Say what? A quirks mode?

说什么? 怪癖模式?

If you don’t declare the doctype, browsers can interpret the document as something else other than HTML and switch into quirks mode, which is, basically, a mode for documents with no doctype declaration.

如果不声明文档类型,浏览器可以将文档解释为HTML之外的其他内容,然后切换到“怪癖”模式,该模式基本上是没有doctype声明的文档的模式。

There can be a lot of quirks in the quirks mode; it can pretty much mess up how your document appears on the screen!

怪癖模式中可能有很多怪癖; 它可能会弄乱您的文档在屏幕上的显示方式!

Quirks mode, almost standard mode, and the full standard mode is something I am going to look into next time.

下次我将研究怪癖模式,几乎是标准模式以及完全标准模式。

For now, take care of your doctype and see you soon!

现在,请照顾好您的文档类型,很快再见!

If you have enjoyed this article and found it beneficial, please consider leaving me a comment or some claps. Thank you!

如果您喜欢这篇文章并认为它很有用,请考虑给我评论或鼓掌。 谢谢!

翻译自: https://www.freecodecamp.org/news/web-developer-interview-q-a-what-does-a-doctype-do-146dd757d7d1/

web开发面试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值