--
Home HTML JAVASCRIPT CSS VUE REACT PYTHON3 JAVA C C++ C# AI GO SQL LINUX VS CODE BOOTSTRAP GIT Local Bookmarks
HTML Tutorial
HTML Tutorial
HTML Introduction
HTML Editor
HTML Basics
HTML Elements
HTML property
HTML Title
HTML Paragraphs
HTML Text Formatting
HTML Links
HTML Head
HTML CSS
HTML Images
HTML Table
HTML Lists
HTML Blocks
HTML Layouts
HTML Forms
HTML Frames
HTML color
HTML colorName
HTML colorValue
HTML script
HTML Character Entities
HTML URL
HTML Quick Reference Lists
HTML Tag Abbreviations and Full Names
HTML Summary
HTML Quiz
XHTML Introduction
HTML5
HTML5 Tutorial
HTML5 Browser Support
HTML5 NewElements
HTML5 Canvas
HTML5 SVG
HTML5 MathML
HTML5 Drag and Drop
HTML5 Geolocation
HTML5 Video(Video)
HTML5 Audio(Audio)
HTML5 Input Type
HTML5 FormsElements
HTML5 Formsproperty
HTML5 Semantic Elements
HTML5 Web Storage
HTML5 Web SQL
HTML5 Web IndexedDB
HTML5 Application Cache
HTML5 Web Workers
HTML5 SSE
HTML5 WebSocket
HTML5 Quiz
HTML(5) Coding Conventions
HTML Media
HTML Media(Media)
HTML Plugins
HTML Audio(Audio)
HTML VideoοΌVideoοΌPlayback
HTML Examples
HTML Reference Manual
HTML Tag Lists (Alphabetical Sort)
HTML Tag Lists (Functional Sort)
HTML property
HTML Event
HTML Canvas
HTML Audio/Video
HTML Valid DOCTYPES
HTML colorName
HTML Color Picker
HTML Character Set
HTML ASCII
HTML ISO-8859-1
HTML Symbol
HTML URL Encoding
HTML Language Code
HTTP Message
HTTP Method
Keyboard Shortcuts
HTML5 Quiz
HTML Media(Media)
explore in depth
web browser
Software
HTML(5) Coding Conventions
HTML Code Conventions
Many Web developers know little about HTML code conventions.
Between 2000 and 2010, many Web developers switched from HTML to XHTML.
Developers who used XHTML developed good HTML coding habits.
For HTML5, we should follow good code conventions. Here are some suggestions:
Use Correct Document Type
The document type declaration is on the first line of an HTML document:
If you want to use lowercase like other tags, you can use:
Use Lowercase Element Names
HTML5 element names can use uppercase and lowercase letters.
Recommended: use lowercase letters:
Mixed case styles are very bad.
Developers typically use lowercase (like XHTML).
Lowercase looks cleaner.
Lowercase is easier to write.
Not recommended:
Very bad:
Recommended:
Close All HTML Elements
In HTML5, you don't have to close all elements (like
elements), but we recommend adding closing tags to every element.
Not recommended:
This is a paragraph.
This is a paragraph.
Recommended:
This is a paragraph.
This is a paragraph.
Close Empty HTML Elements
In HTML5, empty HTML elements don't have to be closed:
We can write:
Or we can write:
In XHTML and XML, the slash (/) is required.
If you expect XML software to use your pages, this style is good to use.
Use Lowercase Attribute Names
HTML5 attribute names allow uppercase and lowercase letters.
We recommend using lowercase attribute names:
Using both uppercase and lowercase is a bad habit.
Developers typically use lowercase (like XHTML).
Lowercase looks cleaner.
Lowercase is easier to write.
Not recommended: