Posts for Web Design

Recommended File Standards for Web Development

These settings help keep files consistent and compatible, reducing problems across different editors, operating systems and web servers.

Definitions

  • Types of files:
    • Text files: Contain text or code that can be viewed and edited using a text editor: .php, .css, .scss, .js, .html, .json, .xml, .svg, .txt, .md, .po, .pot…
    • Binary files: Contain data that generally requires specialised software to view or edit: .jpg, .jpeg, .png, .gif, .webp, .ico, .woff, .woff2, .mo, .pdf, .zip…
  • End Of Line (EOL): Defines the character or characters used to mark the end of each line in a text file. There are three main types:
    • LF (Line Feed, \n, hexadecimal 0A): Used by Linux, macOS and Unix > Use LF for web development files (HTML, CSS, JavaScript, PHP, etc.) to ensure consistency and compatibility across platforms.
    • CRLF (Carriage Return + Line Feed, \r\n, hexadecimal 0D 0A): Used by Windows.
    • CR (Carriage Return, \r, hexadecimal 0D): Used by older Mac systems; now obsolete.
  • Encoding: Defines how characters, letters and symbols are stored in a text file. Unicode is a universal standard that assigns unique numbers (code points) to characters and symbols. UTF-8 and UTF-16 are encodings used to store these code points. Common encoding types include:
    • UTF-8 (Unicode Transformation Format – 8-bit): The most widely used encoding for websites. Supports virtually all languages and symbols. Uses 1 to 4 bytes per Unicode code point, supporting over 1.1 million Unicode code points. UTF-8 is byte-compatible with ASCII.
      • UTF-8 can be saved with or without BOM (Byte Order Mark), an optional three-byte marker (hexadecimal EF BB BF) placed at the beginning of a file to help some applications identify the encoding > Recommendation: Use UTF-8 without BOM for web development files (HTML, CSS, JavaScript, PHP, etc.). Use UTF-8 with BOM only when necessary and supported by the file format, such as when browsers or editors misread accented characters in plain-text files (e.g. llms.txt). In PHP, a BOM can cause “headers already sent” errors.
    • UTF-16 (Unicode Transformation Format – 16-bit): Less common in web development. Uses 2 or 4 bytes per Unicode code point and supports the same characters as UTF-8. It is not byte-compatible with ASCII.
    • ASCII (American Standard Code for Information Interchange): An older encoding supporting English letters, digits, punctuation and control characters. Uses 7 bits per character = 128 characters. Each character is typically stored in 1 byte (8 bits), with 1 bit unused.
    • ISO-8859-1 (International Organization for Standardization – Standard 8859, Part 1) also known as Latin-1 (Western European): An older encoding supporting Western European characters. Uses 1 byte per character, supporting 256 character codes. Byte-compatible with ASCII.
    • Windows-1252 (CP1252 – Code Page 1252): An older Windows encoding supporting Western European languages, including accented characters and special punctuation. Uses 1 byte per character, with 256 possible byte values (251 defined characters). Byte-compatible with ASCII.

For Web Development

  • End Of Line (EOL): LF (\n) > Applies only to text files (1)
  • Encoding: UTF-8 without BOM > Applies only to text files (1)
  • Final newline: End every text file with one newline character > Applies only to text files (1)
  • Trailing whitespace: Remove unnecessary spaces and tabs from the ends of lines, except where they affect content or formatting, such as Markdown line breaks > Applies only to text files (1)
  • Filename case: Linux is case-sensitive, consistently prefer lowercase filenames

For WordPress specifically

  • PHP-only files: Omit the closing ?>
  • File permissions: Normally 644 for files and 755 for folders, depending on hosting configuration and file ownership. Sensitive files such as wp-config.php may require stricter permissions like 640

AI Prompt

Audit all files in this folder and its subfolders without modifying anything.

Check all text files:

  • All text files: Use UTF-8 encoding without BOM, except where BOM is intentionally needed for compatibility.

Check PHP files:

  • All PHP files: Use LF-only line endings (no CRLF or lone CR).
  • All PHP files: End with exactly one newline.
  • PHP-only files: Omit the final closing ?> tag.
  • Mixed PHP/HTML files: Closing ?> tags are allowed where needed, including at the end.

Check CSS/JS files:

  • All files in css/*.css and js/*.js: Use LF-only line endings (no CRLF or lone CR).

Exclude:

  • Binary files.
  • .git metadata.
  • Specific folders: fonts/ img/ languages/ polylang/ src/

Report:

  • The total number of files checked.
  • The number of text, binary, and PHP files checked.
  • Every non-compliant file and the reason it failed.
  • Any exceptions that should not be changed.
  • List your recommendations.

Contact me about: Recommended File Standards for Web Development, by:

  Email »  WhatsApp »