在 Web 开发中编写 CSS 使用合同的最佳方法是什么?
我们的开发团队在两年多前就一直在开发企业网页。 我们很想知道编写 CSS 使用合同的最佳方式是什么。 例如,如果我们有一个 COMP,我们如何就合同达成一致,以便我们的开发人员和设计师达成一致,并且我们不必回去。
有没有可用于此类技术写作的工具?
CSS 和 HTML 页面中信息的线程持有量如何? 我们的一些设计师认为有些内容应该直接放入 HTML 页面。 一般的观点是,所有样式都应该放在 CSS 中,而其他所有内容都应该放在 html 中。
感谢您的输入。
Our Dev team had been developing enterprise web page more than 2 years ago. We are curious to know what is the best way to write a contract for CSS usage. For example, if we have a COMP, how we agree on a contract so our developers and our designers agree and we don't have to go back.
Is there a tool that is available for this type of technical writing?
What is the threadhold of information put in the CSS versus on the HTML page? Some of our designers thing that some things should go directly into the HTML page. The general opinion is that everything that is style should go in a CSS and all else in the html.
Thanks for your input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果我的样式是一次性的、一次性使用的页面,我会考虑将其放在该页面的标题中,因为我的模板系统允许这样做。
但是,您永远不应该使用内联样式。 即使您一次性制作一个包含块的页面。 这样,如果您发现“一次性”项目成为站点范围内的样式,您可以简单地将 CSS 移至外部 CSS 文件中,而无需编辑内容。
If I have style that is for a one time, single use page, I will consider putting it in the header of that page, as my templating system allows for that.
However you should never use inline styles. Even if you do a page with a block in it for a one off. That way should you find that you "one time" item becomes a site wide style, you can simply move the CSS into the external CSS file and not edit the content.
好吧,如果一个网页本身有非常具体的 CSS,我想有一个在页面中定义 CSS 的参数,否则我总是将 CSS 放在外部文件中。
尽量避免或至少最小化将 CSS 内联为 HTML 元素上的样式属性,但这将是一个需要管理的 PITA。
大多数页面将由标准内容样式的模板驱动,因此 CSS 样式将在外部文件中定义。
您可能需要考虑的一件事是 CSS 文件的数量 - 有些人建议您应该将其最小化为站点范围或每个模板(或站点区域)的一个文件,以最大程度地减少对服务器的 HTTP 请求并避免延迟 CSS 加载和有趣的样式直到那时。
那么这个“CSS使用契约”实际上只是HTML页面的编码标准?
Well, if a webpage has very specific CSS just for itself, I guess there is an argument for defining the CSS in the page, otherwise I would always have the CSS in an external file.
Try to avoid or at least minimise in-lining the CSS as a style attribute on HTML elements though, that would be a PITA to manage.
Most pages will be template driven with standard content styles, and thus the CSS styles will be defined in external files.
One thing you might want to think about are the number of CSS files - some people suggest that you should minimise this to just one file site-wide or per-template (or area of the site) to minimise HTTP requests to the server and avoid delayed CSS loading and funny looking styling up until that point.
So this "contract for CSS usage" is actually just a coding standard for HTML pages?
我是一个纯粹主义者,所以对我来说 HTML 是针对内容和结构的,CSS 是针对布局和结构的。 造型。 这确实是他们每个人被创造的目的。
请参阅 CSS Zen Garden 了解一个很好的示例。 相同的 HTML 和数百种不同的布局和布局 设计。
您的设计师将样式设置在 HTML 中的原因是什么?
编辑:这里的主要目标是整个网站的一致性,对吗? 您从每个页面中抽象出来的内容越多,您需要进行的更改就越少。
I'm a purist, so for me HTML is for content and structure and CSS is for layout & styling. That's really what each of them were created for.
See CSS Zen Garden for a great example of this. Same HTML and hundreds of different layouts & designs.
What are the reasons your designers give for styling to be in the HTML?
Edit: The main goal here is consistency across the site, correct? The more you have abstracted away from each page, the fewer changes you'll have to make.
HTML 应该只编码信息而不是样式的想法称为语义标记。 它具有您已经了解的几个优点,例如关注点分离,以及一些您可能没有考虑过的优点。
如果您坚持网络标准并将样式和内容分开,您最终也会得到一个更适合残障人士访问的页面。
如果您需要为特定页面设置不同的样式,请仅针对该页面使用单独的 CSS 包含文件,然后在要设置样式的元素上使用 CSS 类。
The idea that the HTML should merely encode information and not style is called semantic markup. It has several advantages that you already know about, like separation of concerns, and a few that you probably haven't thought about.
If you stick to the web standards and separate your style and content you will also end up with a page that is more accessible to those with disabilities.
If you need to have some things styled differently for a specific page, use separate CSS include file for that page only and then use a CSS class on the element you want to style.