Detailed explanation of BBC's strict CSS coding specifications
This article discusses the BBC's CSS coding specifications, which are well-known in the industry, emphasizing best practices, readability without CSS/JS support, and compliance with W3C standards.
Core points:
- BBC's CSS specification focuses on best practices and focuses on code readability, ensuring accessibility of web page content even when CSS and JavaScript are disabled, and strictly following the published W3C recommendations. The
- specification contains specific rules, such as prohibiting the use of
!important
, mandating the page background color, and using compressed external stylesheets. Inline styles are prohibited and external CSS files cannot be loaded with@import
to avoid potential browser caching issues. - Although it can be challenging for novice developers, these guides provide well-documented documentation to help avoid basic usability errors. The specification also promotes concise, efficient and easy-to-maintain code through clear naming conventions, the use of vendor prefixes, and suggestions on CSS file annotations and organization.
General CSS Principles:
BBC uses XHTML 1.0 Strict as the content carrier, and the guide stipulates that web page content must be readable without CSS or JavaScript enabled. Many developers ignore this in order to quickly add the latest jQuery widgets. Most browsers (or extensions like Web Developer Toolbar) allow disabling CSS and scripts. If the content is unreadable, it cannot be read by Google and screen readers. According to the guidelines, all CSSs must comply with published W3C recommendations. This can cause some problems as it seems to exclude vendor prefix properties such as -moz-border-radius
and -webkit-box-shadow
. However, the BBC website does use them with caution. !important
is forbidden because it overwrites the user style. This is a bit harsh because it is useful for IE6 fixes. That being said, I have also abused it for quick and rude modifications when the root cause of the cascade problem should be addressed. Finally, if you have given up on IE6, consider it for the BBC coders who are still testing in IE5.5! CSS in IE5.5 is especially bad: it tries to parse attributes, but it fails miserably.
CSS implementation:
All CSS is implemented in the form of a compressed external stylesheet, although CSS in the HTML header is allowed when a rule is required for a particular page. Inline styles are forbidden. This is very good. Any coder found using inline styles should revoke his Web development license! Interestingly, external CSS files cannot be loaded using @import
because it affects browser cache. is that so? I suspect this is no longer the case in modern browsers.
Type and color:
A common font name (serif, sans-serif, cursive, or monospace) must be added at the end of all font-family
properties. Again, this is something developers often forget: Not everyone has Arial or Helvetica on their computers. I like this double negative rule: > Typesetting size Not to use units that are not resized in all browsers, such as px and pt, except for print style sheets.
Developer paradise or hell?
If you have been in the industry for a while, you may have absorbed many of the guidelines developed by the BBC. But how do new developers deal with it? On the positive side, these expectations are well documented and can help coders avoid basic usability errors. However, development itself is hard enough—most people struggle to cope with multiple rules and regulations defined for 24 interrelated technologies. Does your company implement strict coding guidelines? Are they aligned or are they quite flexible? Are they reasonable or ridiculous? Are they updated regularly, or are you still writing code for Netscape 3.0? Will the guide help or hinder your daily development tasks? I also want to hear from any BBC developer...Did you strictly follow the rules or use them secretly when the manager is away?
!important
What are the key differences between BBC’s CSS coding standards and other popular standards like Google or WordPress?
The BBC’s CSS coding standards are designed to ensure consistency and readability across all their digital content. They emphasize the use of lowercase, hyphen-separated class and ID names, and discourage the use of ID selectors for styling. On the other hand, Google’s style guide encourages the use of meaningful or generic ID and class names, and WordPress’s standards recommend specific naming conventions for classes and IDs. Each of these standards has its own unique approach, but all aim to promote clean, efficient, and maintainable code.
How does the BBC’s CSS coding standards handle vendor prefixes?
The BBC’s CSS coding standards recommend using vendor prefixes for CSS properties that are not yet standardized or fully supported across all browsers. This ensures that the CSS code will work correctly across different browsers, even if they interpret certain CSS properties differently. This is a common practice in many CSS coding standards, including those of Google and Mozilla.
What is the BBC’s stance on using shorthand properties in CSS?
The BBC’s CSS coding standards encourage the use of shorthand properties whenever possible. This is to keep the code concise and easy to read. However, they also caution developers to fully understand the implications of shorthand properties, as they can sometimes lead to unexpected results if not used correctly.
How does the BBC’s CSS coding standards approach commenting in CSS?
The BBC’s CSS coding standards recommend using comments to explain the purpose and functionality of the code. They suggest using comments to separate sections of the CSS file, and to provide context for complex or unusual code. This is in line with best practices for coding standards, as comments can greatly improve the readability and maintainable of the code.
What are the BBC’s guidelines for ordering CSS properties?
The BBC’s CSS coding standards do not specify a particular order for CSS properties. However, they do recommend grouping related properties together to improve readability. This is a common practice in many CSS coding standards, as it makes the code easier to understand and maintain.
How does the BBC’s CSS coding standards handle CSS selectors?
The BBC’s CSS coding standards recommend using class selectors over ID selectors for styling, as they are more flexible and reusable. They also discourage the use of overly specific selectors, as they can make the code harder to maintain and can lead to unnecessary complexity.
What is the BBC’s stance on using !important in CSS?
The BBC’s CSS coding standards discourage the use of !important, as it can make the code harder to understand and maintain. They recommend using more specific selectors or reordering the CSS rules instead. This is a common recommendation in many CSS coding standards, as the use of !important can often be a sign of poor CSS architecture.
How does the BBC’s CSS coding standards approach the use of media queries?
The BBC’s CSS coding standards recommend using media queries to make the website responsive and to ensure that it displays correctly on different devices. They suggest placing media queries at the end of the CSS file, and organizing them from smallest to largest based on the width of the viewport.
What are the BBC’s guidelines for CSS file organization?
The BBC’s CSS coding standards recommend organizing the CSS file in a logical and consistent manner. They suggest separating different sections of the CSS file with comments, and grouping related properties together. This can greatly improve the readability and maintainability of the code.
How does the BBC’s CSS coding standards handle CSS animations and transitions?
The BBC’s CSS coding standards recommend using CSS animations and transitions sparingly, as they can sometimes lead to performance issues. They suggest using them only when necessary, and to always test the performance of the website after adding animations or transitions.
The above is the detailed content of Do You Adhere to Strict BBC-Style CSS Coding Standards?. For more information, please follow other related articles on the PHP Chinese website!

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)
