Code Monkey home page Code Monkey logo

main.css's Introduction

main.css

A repository for the development of the HTML5 Boilerplate CSS file, style.css.

Historically, the file shipped with HTML5 Boilerplate was called main.css, hence the name of this project. It's since been renamed to style.css. Just in case you were confused.

This project includes both the whole main.css file as well as component files used to generate main.css. This way you can either pull in the whole file, as we do in HTML5 Boilerplate (renaming it to style.css) or you can pull in the individual files as needed.

GitHub Super-Linter

Quick start

Choose one of the following options:

  • Download as part of the latest stable release of HTML5 Boilerplate from html5boilerplate.com.
  • Clone the git repo — git clone https://github.com/h5bp/main.css.git - and checkout the tagged release you'd like to use.
  • Install with npm: npm install main.css and pull in what you need from the resulting node_modules/main.css/distfolder
  • Install with yarn: yarn add main.css and pull in what you need from the resulting node_modules/main.css/distfolder

Features

The project contains the following files, which combine to create the different sections of main.css.

_base.css

Several base styles are included. These styles:

  • provide basic typography settings that improve text readability
  • protect against unwanted text-shadow during text highlighting
  • tweak the default alignment of some elements (e.g.: img, video, fieldset, textarea)

_helpers.css

Along with the base styles, we also provide some commonly used helper classes.

.hidden

The hidden class can be added to any element that you want to hide visually and from screen readers. It could be an element that will be populated and displayed later, or an element you will hide with JavaScript.

.visually-hidden

The visually-hidden class can be added to any element that you want to hide visually, while still have its content accessible to screen readers.

.invisible

The invisible class can be added to any element that you want to hide visually and from screen readers, but without affecting the layout.

As opposed to the hidden class that effectively removes the element from the layout, the invisible class will simply make the element invisible while keeping it in the flow and not affecting the positioning of the surrounding content.

.clearfix

The clearfix class can be added to any element to ensure that it always fully contains its floated children.

Over the years there have been many variants of the clearfix hack, but currently, we use the micro clearfix.

_mqs.css

We include placeholder media queries to help you build up your mobile styles for wider viewports and high-resolution displays. It's recommended that you adapt these media queries based on the content of your site rather than mirroring the fixed dimensions of specific devices.

If you do not want to take the mobile first approach, you can simply edit or remove these placeholder media queries. One possibility would be to work from wide viewports down, and use max-width media queries instead (e.g.: @media only screen and (max-width: 480px)).

_print.css

Lastly, we provide some useful print styles that will optimize the printing process, as well as make the printed pages easier to read.

At printing time, these styles will:

  • strip all background colors, change the font color to black, and remove the text-shadow — done in order to help save printer ink and speed up the printing process

  • underline and expand links to include the URL — done in order to allow users to know where to refer to
    (exceptions to this are: the links that are fragment identifiers, or use the javascript: pseudo protocol)

  • expand abbreviations to include the full description — done in order to allow users to know what the abbreviations stands for

  • provide instructions on how browsers should break the content into pages and on orphans/widows, namely, we instruct supporting browsers that they should:

    • prevent block quotations, preformatted text, images and table rows from being split onto two different pages
    • ensure that headings never appear on a different page than the text they are associated with
    • ensure that orphans and widows do not appear on printed pages

The print styles are included along with the other css to avoid the additional HTTP request. Also, they should always be included last, so that the other styles can be overwritten.

Browser support

We use the default browserslist configuration which translates to this full list of browsers.

Contributing

Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the guidelines:

License

The code is available under the MIT license.

main.css's People

Contributors

antleblanc avatar arunsathiya avatar byurhannurula avatar coliff avatar dependabot[bot] avatar jeroen-matthijssens avatar mattbrundage avatar roblarsen avatar romamatusevich avatar vltansky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

main.css's Issues

Add .npmignore

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Notes:

I think it might make sense to add an .npmignore to the repo and exclude the files which aren't needed for users who are pulling main.css to their projects via npm/yarn. It's not a big deal really, but there's no need for the .github directory and all those various configs. Will reduce number of files when importing.

Add a CHANGELOG.md

I think it'd be good to add a CHANGELOG so folks who have downloaded the repo can see what has changed between versions, especially if there have been class name changes etc.

I think we should either add a CHANGELOG.md to the root of the project repo and list everything there like we do for HTML5 Boilerplate - or if not (to reduce duplication/effort) we could have an almost empty CHANGELOG.md with just include a link to the releases page on GitHub (https://github.com/h5bp/main.css/releases) which is less useful but better than nothing at all.

.sr-only used on inputs causes huge problems in some scrolling setups

The current sr-only utility class uses position: absolute with no coordinates as the main method to remove and stop element from affecting layout.

This doesn't play well with some scrolling setups combined with browsers new "feature" of scrolling to elements it thinks user is interacting with.

The problem is isolated and explained here (affects Chrome): https://output.jsbin.com/tamuvac

The fix would be to instead use:

position: fixed;
left: 0;
top: 0;

Remove IE11 from browserlist config

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Notes:

We should remove IE 11 from the browserlist config field in package.json now that it is no longer supported by H5BP.

Ship v3.0.0

This Issue is to track progress of releasing main.css v3.0.0 🚢

Release Notes

  • Rename sr-only' class to visually-hidden` #109 (this is a breaking change so that's why version is bumped to v3)
  • Remove print thead rule #101
  • Remove Vendor-prefixed ::selection #93
  • Lots of dev dependency and npm publishing updates

Todo List

Ship v2.0.0

This issue is to track progress of releasing the first update to main.css! 🚢

Release Notes

  • Add .stylelintrc config (#18)
  • Rename visuallyhidden to sr-only (#27)
  • Fix broken link to 'printing tables' page (#20)
  • Alphabetize properties (#20)
  • Add stylelint-config-recommended to package.json
  • Add CONTRIBUTORS.md(#9)
  • Minor devdeps and README updates (#11), (#24)

Todo List

  • Deal with currently open PRs
  • Update CHANGELOG.md
  • Publish v2.0.0 on GitHub (@roblarsen)
  • Publish v2.0.0 on NPM (@roblarsen)

visuallyhidden > sr-only

I'd like to propose that we rename the visuallyhidden class to sr-only.

  • visuallyhidden isn't super clear exactly what it is for. The class is intended to be used for text which is only for screen readers so I think sr-only is more obvious and makes more sense
  • The sr-only class is used by Bootstrap, the world's most popular CSS framework. It's sort of good to align with that.
  • visuallyhidden isn't a word and is always flagged as a typo which bugs me :-)

Ship v2.1.0

This Issue is to track progress of releasing main.css v2.1.0 🚢

Release Notes

  • Updates to stylelint-config-standard and add lint script (#55 )
  • Add .npmignore (#54 )
  • Add [hidden] attribute support (#53 )
  • Update _print.css (#52 )
  • Remove .browserupgrade class (#51 )
  • Update Supported browsers (#58 )

Todo List

Build script to check and report of any Stylelint issues

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

It'd be good if the Gulp build script automatically checked and either fix or report/warn of any Stylelint issues.

Use Browserslist default

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

We currently specify supported browsers with a browserslist config in the package.json. I think it makes more sense to remove this so it simply uses the Browserslist defaults which is similar to ours anyway.
https://browsersl.ist/#q=defaults

The defaults query is a shortcut for > 0.5%, last 2 versions, Firefox ESR, not dead. It matches recent versions of popular and supported browsers worldwide and includes Firefox Extended Support Release which is updated roughly annually.

Broken URL for Printing Tables section

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Bug reports

I'm not able to access to the article by using this URL: http://css-discuss.incutio.com/wiki/Printing_Tables

My proposal is to replace it by an article from the Smashing Magazine:

I will linked to this issue the corresponding pull request. Hope it helps you. Thanks

inconsistent indenting of the CSS in the `dist` dir

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

hey @roblarsen - when I make a build the indenting of the CSS in the dist dir is different (it's better and more consistent). I'll make a PR for this as assume it was previously unintended.

Inline @media print CSS shouldn't be inline anymore

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

In version 8 of HTML5Boilerplate, the print styles are inlined using @media print with this comment above:

/* ==========================================================================
   Print styles.
   Inlined to avoid the additional HTTP request:
   https://www.phpied.com/delay-loading-your-print-css/
   ========================================================================== */

The article, from 2007, does not seem relevant anymore. Many CSS developers are taking advantage of the fact that print-media stylesheets are now loaded asynchronously. (I don't find any specification for this, but it seems to be common practice now, and I see a reference to the async nature of print style sheets at https://developer.mozilla.org/en-US/docs/Learn/Performance/CSS)

So … I think it might be a good idea to separate out the print CSS into a separate file, loaded separately and asynchronously, to allow the main.css file to be a bit smaller, which speeds up initial page load.

Improve actual ESLint configuration

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

The actual ESLint configuration seems to be de-synchronized with the actual sources of the repository.

Here is a list of small details reported:

  • ESLint isn't installed as a devDependencies.
  • The mocha plugin is required but it's not used.
  • No entry in the script section that refer to the ESLint CLI.

Proposal:

  • Install all missing devDependencies.
  • Keep the bare minimum as an ESLint configuration.
  • Add script entry that runs ESLint.

Update Supported Browsers Config & Docs

I think we should modify the browserslist supported browsers to be:

0.5%, last 2 versions, Firefox ESR, not dead, IE11.

These are the browerlists defaults(https://github.com/browserslist/browserslist#queries) and includes a better range of defaults - but with the addition of specifying IE11.

The best practises section is a good reference: https://github.com/browserslist/browserslist#best-practices

Note: Also need to update the list at: https://github.com/h5bp/main.css/blob/master/README.md#browser-support

Add a Lint GitHub Action Workflow

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

It'd be neat to add a GitHub Action Lint workflow. I think we could use Super Linter (https://github.com/github/super-linter), maybe with the following config to start with.

name: Lint Code Base

on:
  push:
    branches: [main]

jobs:
  build:
    name: Lint Code Base
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v2

      - name: Lint Code Base
        uses: docker://github/super-linter:v3
        env:
          DEFAULT_BRANCH: main
          VALIDATE_ALL_CODEBASE: false
          VALIDATE_EDITORCONFIG: false
          VALIDATE_MARKDOWN: false
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Break up main.css into component parts, implement build

Okay! Months later I return from the wilderness.

This issue was originally about pre-processors and all that and after kicking the tires on it, it seems like a waste of time, so this is now simpler.

  1. Break main.css into muliple files
  2. combine them back together to create voltron the new main.css
  3. copy the component files to ./dist/ so that people can ingest individual files as needed

This will be the 1.0.0 release 🥇

npm run lint_js is failing

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))
  1. Run npm run lint:js
  2. Error:
 0:0  error  Parsing error: require() of ES Module C:\....\main.css\node_modules\eslint-scope\lib\definition.js from C:\....\main.css\node_modules\babel-eslint\lib\require-from-eslint.js not supported.
Instead change the require of definition.js in C:\....\main.css\node_modules\babel-eslint\lib\require-from-eslint.js 
to a dynamic import() which is available in all CommonJS modules

✖ 1 problem (1 error, 0 warnings)

(node:14380) [ESLINT_PERSONAL_CONFIG_SUPPRESS] DeprecationWarning: '~/.eslintrc.*' config files have been deprecated. Please remove it or add 
'root:true' to the config files in your projects in order to avoid loading '~/.eslintrc.*' accidentally. (found in "..\..\..\.eslintrc")      
(Use `node --trace-deprecation ...` to show where the warning was created)

macOS - VoiceOver / Chrome announcing visually hidden text out of order

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Steps to reproduce

  1. Visit https://codepen.io/joe-watkins/pen/OjpqxL with Safari or Chrome and VoiceOver activated.
  2. Tab to each link and listen to how they are announced.

Expected Results

The visually hidden text using HTML5 boilerplate's .visuallyhidden {} will be announced in the order that it is within the markup.

Actual Results

The order of the text is not announced does not match the markup order. Visually hidden text is announced before visible text copy.

Potential fix

After some testing, I've found that using position: relative; and display: inline-block; appears to solve this. e.g.

.visuallyhidden {
	border: 0;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: relative; // different - for reading order in macOS VO
	display: inline-block; // new - for reading order in macOS VO
}

SR Tested (works in)

  • Win Edge,IE11,FF,Chrome JAWS 18/17
  • Win IE11,FF,Chrome NVDA
  • macOS Seirra Safari,Chrome,FF VoiceOver

Browsers tested (works - hides text in)

  • Win Edge, IE11, IE10, IE9, IE8, FF 53, Chrome 60
  • macOS Seirra Safari 10.2, Chrome 60, FF 54

Video screencast of experience

Everything Is AWESOME

I'd love to get some thoughts on this and I'd be happy to create a PR if everyone is into it :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.