What does DOCTYPE do?

Gather sand into a tower, make a little progress every day


⭐ Introduction to the column

Front-end Getting Started Tour: Explore the wonderful world of Web development Remember to click the link above or on the right to subscribe to this column Oh Geometry will take you on a front-end journey

Welcome to the front-end introductory tour! This column is tailored for those friends who are interested in web development and have just stepped into the front-end field. Whether you are a complete novice or have some basic developers, here will provide you with a systematic and friendly learning platform. In this column, we will update it every day in the form of questions and answers, presenting selected front-end knowledge points and answers to frequently asked questions. Through the question-and-answer format, we hope to more directly respond to readers' questions about front-end technology, and help everyone gradually build a solid foundation. Whether it's HTML, CSS, JavaScript, or a variety of commonly used frameworks and tools, we'll explain concepts in simple terms and provide practical examples and exercises to reinforce what you've learned. At the same time, we will also share some practical tips and best practices to help you better understand and use various technologies in front-end development.

Not only that, we also regularly launch some practical project tutorials, so that you can apply the knowledge you have learned to actual development. Through the practice of actual projects, you will be able to better understand the workflow and methodology of front-end development, and develop your ability to solve problems and develop independently. We believe that only by continuous accumulation and practice can we truly master front-end development technology. So get ready for the challenge and bravely embark on this front-end introductory journey! Whether you're looking for a career transition, upskilling or personal interest, we're committed to providing you with the highest quality learning resources and support. Let's explore the wonderful world of web development together! Join the front-end introductory journey and become an excellent front-end developer! Let's set sail on the front-end journey


⭐ What does DOCTYPE do?

DOCTYPE (DocumentTypeDeclaration) is an important statement in the HTML document, which is used to specify the HTML version adopted by the current document. It is usually located at the beginning of an HTML document and uses the following syntax format: <!DOCTYPE html>Here are some common DOCTYPE declarations and their corresponding HTML versions and features:

HTML5: The simplest and most commonly used DOCTYPE declaration for web pages written using the HTML5 specification. Example:

<!DOCTYPE html>   

HTML 4.01 Strict: Strict mode, which requires compliance with the HTML 4.01 specification, and does not allow outdated, obsolete or deprecated elements and attributes. Example:

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

HTML 4.01 Transitional: Transitional mode, allowing the use of some obsolete or deprecated elements and attributes to maintain compatibility with older browsers. Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  

XHTML 1.0 Strict: An XML-based strict mode that requires compliance with the XHTML 1.0 specification, all tags must be closed, and attribute values ​​must be enclosed in quotation marks. Example:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   

XHTML 1.0 Transitional: An XML-based transition mode that allows the use of some obsolete or deprecated elements and attributes. Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   

XHTML 1.1: An XML-based schema with stricter specifications requiring that all tags must be closed and attribute values ​​must be quoted. Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">   

In summary, its functions mainly include the following aspects:

  1. Standardize browser behavior: DOCTYPE declarations can help browsers parse and render HTML documents correctly. Different HTML versions have different specifications and features. By specifying the correct DOCTYPE, you can ensure that the browser parses the page according to the specifications of the corresponding version.
  2. Avoid mixed mode: In the early HTML standards, if the DOCTYPE declaration was not provided or the wrong declaration was provided, the browser would enter the mixed mode (Quirks Mode), which means that the browser will try to be backward compatible with the old version of HTML, but It may also cause inconsistent page display or compatibility issues. Entering promiscuous mode can be avoided by explicitly specifying the correct DOCTYPE.
  3. Support for new features: With the continuous update and evolution of the HTML standard, many new features and grammar rules have been introduced in the new version. By using an appropriate DOCTYPE statement, you can tell the browser which HTML version the current page adopts, and enable it to understand and support the newly added functions and syntax in this version.
  4. Prompt for validation tools: The DOCTYPE declaration also serves as a hint for validation tools. Validation tools (such as W3C's HTML validator) can judge whether a document conforms to the corresponding version of the HTML specification according to the DOCTYPE declaration, thereby helping developers find and fix errors in the code.

To sum up, the DOCTYPE declaration plays a role in standardizing browser behavior, avoiding promiscuous mode, supporting new features and prompting validation tools in HTML documents. Using the correct DOCTYPE declaration helps ensure consistent display of the page on different browsers, and ensures that the page is parsed and rendered according to the latest HTML standards.


⭐ Written at the end

This column is suitable for a wide range of readers, suitable for front-end beginners; or partners who have never studied the front-end and are interested in the front-end, or back-end students who want to better show themselves and expand some front-end knowledge points during the interview process, so If you have a front-end foundation and follow this column to learn, it can also help you to check and fill in the gaps to a great extent. Since the blogger himself does the content output, if there are any flaws in the article, you can contact me on the left side of the homepage , we make progress together, and at the same time recommend several columns for everyone, interested partners can subscribe: In addition to the columns below, you can also go to my homepage to see other columns;

Front-end games (free) This column will take you into a world full of creativity and fun. By using the basic knowledge of HTML, CSS and JavaScript, we will build various interesting page games together. Whether you're a beginner or have some front-end development experience, this column is for you. We'll start with the basics and guide you step-by-step through the skills you need to build web games. Through practical cases and exercises, you will learn how to use HTML to build page structure, use CSS to beautify the game interface, and use JavaScript to add interactive and dynamic effects to the game. In this column, we'll cover various types of mini-games, including maze games, arkanoid, snake, minesweeper, calculator, airplane wars, tic tac toe, puzzles, mazes, and more. Each project guides you through the building process in clear and concise steps, with detailed explanations and code examples. At the same time, we will also share some optimization tips and best practices to help you improve page performance and user experience. Whether you are looking for an interesting project to exercise your front-end skills, or are interested in web game development, the front-end small game column will be your best choice. Click to subscribe to the front-end game column

Vue3 transparent tutorial [from zero to one] (paid) Welcome to the Vue3 transparent tutorial! This column aims to provide you with comprehensive Vue3-related technical knowledge. If you have some Vue2 experience, this column can help you master the core concepts and usage of Vue3. We'll walk you through building a complete Vue application from scratch, step by step. Through actual cases and exercises, you will learn how to use Vue3's template syntax, component development, state management, routing and other functions. We will also introduce some advanced features, such as Composition API and Teleport, etc., to help you better understand and apply the new features of Vue3. In this column, we'll guide you through each project in clear and concise steps, with detailed explanations and sample code. At the same time, we will also share some common problems and solutions in Vue3 development to help you overcome difficulties and improve development efficiency. Whether you want to learn Vue3 in depth or need a comprehensive guide to building front-end projects, the Vue3 transparent tutorial column will become your indispensable resource. Click to subscribe to the Vue3 transparent tutorial [from zero to one] column

TypeScript Getting Started Guide (Free) is a column designed to help you get started quickly and master TypeScript-related technologies. Through concise and clear language and rich sample code, we will explain the basic concepts, syntax and features of TypeScript in depth. Whether you are a beginner or an experienced developer, you can find a learning path that suits you here. From core features such as type annotations, interfaces, and classes to modular development, tool configuration, and integration with common front-end frameworks, we will cover all aspects comprehensively. By reading this column, you will be able to improve the reliability and maintainability of JavaScript code, and provide better code quality and development efficiency for your own projects. Let's embark on this wonderful and challenging TypeScript journey together! Click to subscribe to the TypeScript Getting Started Guide column

Guess you like

Origin blog.csdn.net/JHXL_/article/details/132081017