Cover image for Style beautiful web pages without writing any CSS. Using W3.CSS.

Style beautiful web pages without writing any CSS. Using W3.CSS.

imalittletester profile image Corina Pip ・4 min read

Recently i was looking for a way to create some web pages to use in my upcoming technical workshops as demo pages. I did not want to spend too much time styling them, but at the same time i wanted them to look nice and modern. Using CSS at this point was out of the question, since that would have been too much effort for what i wanted to create. I stumbled on something that fit perfectly with my wishes, namely W3.CSS.
W3.CSS is a modern, easy to learn CSS framework, that allows for responsiveness and works across a variety of browsers and platforms.

Using it in your project

In order to style pages using this framework, you only need to import it by adding the following entry in your HTML page:

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

OK, but what can you style?

To get an overall idea of what this framework offers, you can checkout their intro page. You can style buttons, navigation bars, dropdowns and lists, just to name a few. You can also apply predefined colors, or apply color tone effects on images. And of course you can easily apply padding or margins, or even set a layout on the page that will help items fall into the right place. Or left place, if you want.

Hmmm, interesting, but how?

The summary of it is: to any HTML element that you want to style, you need to add a class attribute. The values of the class attributes will determine the styling. For example, to add a predefined color to an element, like cyan, the element's class needs to be "w3-cyan". To add a simple border, you need to add the "w3-border" class. Checkout the "W3.CSS" site for all these values and all the possible styling you can apply.

What about the cover image of this article?

Ah yes. This image uses only "W3.CSS" for styling, just to give you a taste of this framework.

Let me tell you what i used to create it. The button (on the left) and the image (on the right, together with the text below it) are placed in a div element that looks like this:

<div class="w3-display-middle w3-container w3-border-top w3-border-bottom w3-margin w3-border-teal">

This means:

  • w3-display-middle - the element will be placed in the middle of the page. Elements can be displayed: top left, top middle, top right, left, middle, right or bottom left, bottom middle and bottom right.
  • w3-container - an element with a left and right padding of 16px to any other element.
  • w3-border-top and w3-border-bottom - add the top and lower borders. The color of the border, teal, is given by w3-border-teal. You could also create round borders, or thick ones.
  • w3-margin - adds a 16px margin to all sides of this container.

The button on the left, inside the container, has the following HTML code:

<button class="w3-btn w3-border w3-teal w3-margin w3-padding-large w3-left w3-large w3-opacity">Who's

Let's see what this all means:

  • w3-btn - creates a rectangular button, that, when hovered, shows a nice shadow.
  • w3-border - provides a thin border to the button.
  • w3-teal - sets the button color to teal. See 'Colors' for other available colors.
  • w3-left - is the equivalent of float:left from CSS.
  • w3-large - specifies that the buttons' text is larger than the default size of text.
  • w3-opacity - gives a transparency effect to the button. See 'Effects' for further details and other values.

Now, for the right side, where the image is:

<div class="w3-card-4 w3-border w3-left w3-padding-large w3-margin w3-teal">
        <img src="https://farm2.staticflickr.com/1870/44322750771_d9eb2522f8_n.jpg"
             class="w3-sepia-min w3-round-xlarge">
        <div class="w3-container w3-center">
            <h4><b>We are. Yes we are.</b></h4>

As you can see, the image (an img tag) and the text below it are placed inside a styled div. The attribute that defines what this div does is w3-card-4. It specifies that the div is a sort of a container (it is used mostly to create 'paper card'-like containers), with a shadow border of 4px. The card div element also has a border, float location, padding, margin and background color specified (which i already described in the above elements).

The image is styled with two attributes: there is a Sepia color effect applied on it, which is given by the w3-sepia-min attribute, and its' corners are rounded quite a bit as per the w3-round-xlarge attribute.

For the text displayed right below the image, another div element is created to encompass it, of type w3-container. The attribute w3-center specifies that all the text from inside the div will be displayed in a centered position relative to the div. The text itself is then only a bolded h4 one.

Confused already? Don't hesitate to check out the W3.CSS site for all the details and the options they offer for easily creating stylish web pages.

Posted on by:

imalittletester profile

Corina Pip


Testing and automation enthusiast. Test lead. Speaker. Blogger. GitHub committer (https://github.com/iamalittletester/thewaiter). Comics (https://imalittletester.com/category/comics/).


markdown guide

The dream of the semantic web is over, isn't it?
By which I mean, this is a mix of style and content which means that if you want to re-theme your website you'll have to change all the HTML :(


Indeed. I understand why some people choose this approach, but it defeats the purpose of classes. I want to define a class of objects which share attributes because those objects represent the same thing on the page (e.g., headings). Using, e.g., "w3-teal" on those headings is essentially just moving my CSS into my HTML, and making it more cumbersome to change that one color in the future. I'd rather just define my "heading" class with whatever shade of teal I want, then change that one color in one place in the future.

Again, I get why some people use libraries like this, but I've noticed a move toward this approach even when it creates more problems than it solves (it doesn't make sense for most enterprise web apps). And the unfortunate reality is that some developers just don't want to spend time understanding CSS to the degree that they do JavaScript.


I think tailwindcss is a nice middle-ground - you can use the pure 'utility' approach like :

<div class="shadow bg-primary px-4 py-8">Nav here</div>

But you can also 'compose' classes out of the utilities in your css/sass by doing :

.nav {
  @apply shadow bg-primary px-4 py-8;
<div class="nav">Nav here</div>

I've found it works quite well - those one-off things can keep their one-off utlities, but as you find common/re-used blocks and components you can style them as one thing.


That makes more sense to me because it's still keeping the presentation stuff in the presentation box.


Using classes like that isn't technically against the principals of semantic web design. Bulma has a very similar class syntax, but makes a point to not style any HTML elements directly and encourages using things besides <div>s when appropriate. I can't speak for W3.CSS, but there are serious benefits to designing classes in this way.


Class attributes aren't semantic content, so nothing wrong with this approach really. The problem with inline styles is that they're too limited: you can't constrain by media queries or other pseudo elements or pseudo classes. Atomic CSS can handle that, and it does so in a way that's much easier to use than fiddling with CSS manually. I recommend checking out the tachyons CSS toolkit.


That's true. They also offer something in regards to themes, but i haven't tried it: w3schools.com/w3css/w3css_color_th.... I think it all depends on the purpose of the development and what kind of pages you are creating. This is a quick win in many situations.


Why would your content be in your markup files? :O
It should be in the API/DB/CMS.


You know there are static websites, right?

And I don't even mean generated static sites. I literally mean sites that don't need an API/DB/CMS because they are pure content and easy to manage in HTML?

Oh, say, for instance most sites hosted on GitHub Pages.

Resume sites. Portfolio sites. Restaurant sites. I can go on and on.

You don't need to over-engineer a 6 page restaurant site that hosts directions, menu, and simple things like that.

Don't overlook those pages -- they're still important and a big chunk of what the web is made of.

I find that unsustainable even for tiny restaurant sites.
For example, you likely have your contact info in the contact page and the footer of every page.
Assuming you at least keep your footers separate, that's still two places to change your phone number, working hours, etc.

And this isn't a root comment, this is a response to the person woeing over having to redo their markup for a restyle.

Well, guess what? CSS Garden doesn't work on real-life markup, only on intentionally superfluous one.


The dream of semantic web is far from over; it's on the rise with an evergreen HTML spec and always-up-to-date browsers. More and more "web designers" are finally realizing that if they don't drop their divs and start using semantic standard components, they'll never be able to cover all the devices which will change too rapidly.

Of course, you can always choose to ignore all that and use a ridiculous syntax like w3-padding-large, but then again, nobody can stop you from smashing your head against the screen either, right?


I see you are totally missing the point of this article. I stated in the initial part how i came to use it, and what was the purpose for it. I had a specific requirement, and this is a solution to my requirement. Whereas you are free to express your dislike, and i'm sure you have better ways of doing things, please be respectful.


Hi Corina,

Atomic CSS was very "hip" some time ago, and I feel that today, when we build applications using incapsulated components, there isn't really a place for "atomisation". We have common styles and configuration, like fonts etc., but every component lives for itself.

Plus, to be quite frank, the syntax is horrible. Using ten classes to style an element that may appear a couple of times is a terrible redundancy and will hurt the document size, its parsing and further maintenance.


"but every component lives for itself"
Please dont' forget that just because many people decide to do "one thing" it doesn't mean it's the ultimate truth. People thought Earth was flat, smoking was good, cocaine was a good medicine etc.
Repeating CSS in every component just because "some folks at Facebook" said it's good for you isn't really a technically convincing argument.
Sure, component based architecture is all fine, but repeating a bunch of CSS properties to every component's scoped CSS will eventually add CSS size, impact performance, and make redesigns harder.
"the syntax is horrible" => subjective opinion.
Redundancy is not repeating classes, because classes ARE MEANT TO BE REPEATED.
Parsing is not impacted. Document size doesn't matter - it's cached anyway.

Please speak with solid arguments and not just personal preference. This type of engineers is what's most annoying in the job.


Hello George,

First off, this is a personal comment on a personal blog posting. It's meant to be subjective and I feel that I have justified my reasoning. This is no scientific debate that needs ten references for every sentence :)

I don't say that components are "the ultimate truth", but using such architecture for a long time (way before I started to use React or even Angular JS) has proven very performant. The key here is composition. If you compose your larger components (or, containers) with some smaller ones, you won't repeat your CSS. I don't think this is the place to discuss pros and cons of componetisation, given the fact that the article is about atomic CSS.

Plus, I still believe that using w3-btn w3-border w3-teal w3-margin w3-padding-large w3-left w3-large w3-opacity to style a simple button, an element that will be repeated multiple times, is redundancy. it will impact your document size and, even cached, it will have to be sent to the client.

Last, but not least, I don't believe that every decision needs only "technically convincing arguments". Sure, it's great to have those and take them under consideration. But if we would decide solely based on technicalities, we would all write using C or even low-level languages.

Now, please don't assume that I am against atomic architecture. I am not. If this suits one's needs – this is great.

We're engineers and our decisions should be based on engineering, not on number of blog posts / hype driven development.

Also I would like to point out words used in your original comment:
"atomic CSS was hip some time ago"
"the syntax is horrible"

you know what's horrible?

.header--login__buton { 
   display: block;
   padding: 10px 0;

.footer--menu__button {
   display: block;
   padding: 10px 0;

compare this with

  <a href="/whatever" class="block-button padding-s">button</a>
  <a href="/whatever" class="block-button padding-s">button</a>

George, this is misunderstanding of BEM principles. Your code should look like this:

.link {
  display: block;
  padding: 10px 0;


.header__link {
  color: red;


<header class="header__container">
  <li><a href="#" class="link header__link">Hi</a></li>
<footer class="footer__container">
  <li><a href="#" class="link">Bye</a></li>

Plus, BEM syntax also isn't the prettiest one :)

George, please don't exaggerate. Yes, our decisions should be based on knowledge, metrics, etc., but also on ease of development, entry and complexity levels, adoption etc. Those factors are extremely important. I know people that would even put those higher than sheer performance, simply because, when your code is really good, differences are a lot less significant than, for example, people quitting after three months because of the tech.

Atomic CSS is easier to use than juggling between nested selectors and having to write CSS classes like:
I think we analyzed enough. This is a technology blog and we should speak like professionals, not like fanboys


They don't deserve the hate they once did. It's a much better resource today than, say, 10 years ago.


Yeah, that's not really a feeling anymore. Look at the statement at top of W3Fools:



No, it’s still the most useless tool for developers. If you need an example, search for the css float property, and compare the result with MDN...


Yes. It’s one one of the most shitty resource for developers.


How is this any better than just using inline style attributes?


I am boycotting anything W3School.

The issue I have with W3School is how unfair they are with overloading the W3 symbol (it's reserved by w3.org, where Sir. Tim Berners-Lee and colleagues writes Specifications for the web).

So, w3css is like what Microsoft does with "SQL", when they. SQL has a Specification, not written by Microsoft. Here, W3School isn't contributing to standards. And aren't fair-play with the W3 name.



So instead of learning some CSS, which is an accepted standard, you're going to learn this, which is a random array of string leveraging the class attribute which is not supposed to be used for styles at all?

w3-btn w3-border w3-teal w3-margin w3-padding-large w3-left w3-large w3-opacity

While I agree with you that W3 css isn’t necessarily a great choice, the popularity of atomic css is on the rise, and with good reason. Also, styles on classes is 100% how CSS is intended.


No. From the WHATWG HTML spec, § 3.2.6 (emphasis mine):

There are no additional restrictions on the tokens authors can use in the class attribute, but authors are encouraged to use values that describe the nature of the content, rather than values that describe the desired presentation of the content.

It doesn't any sense for HTML, which is all about document semantics, to announce that an element is of type "padding-small". Use a class name to categorize an element such as "important-item", "feed-item", etc.

The article claims that you're not writing any CSS. Why in the world would you do class="padding-small" when you can do style="padding: var(--small)", which precisely describes what you want, and is a standardizes way of doing things?

Everyone goes bananas over inline styles, repeating a mantra they've read somewhere about how "it's bad practice", "anti-pattern", and then they splash a class="margin-top-medium". Totally not inlining styles. Nope, not at all.

I encourage you to give this article a read and share your thoughts. I understand the ideology behind separation of concerns, but look at react and vue. Maybe it’s time we challenge this idea as well.


I never said anything about separation of concerns, not did I say that you shouldn't inline styles or that it's a bad thing to do.

There's nothing wrong with inlining styles.

But there's everything wrong with pretending you're not inlining styles when you add a class named padding-small which adds the style { padding: var(--small) }.

This article perfectly describes why it is very different from inline styles.


Please, while I know you disagree with others, be civil and open to new ideas and other viewpoints. It makes this community a better place for everybody!

Wow, that article has literally no left margin.
I wonder what the author meant by that.
Probably that the curtains were blue.

Maybe he forgot to add margin-left to the classes? ;)

Luckily it's an easy markup change that can be done in seconds, without fear of breaking another page that reuses the same semantic class names!

Yup, luckily he has no idea that changing styles means changing styles, and not changing markup. Ignorance is a bliss indeed!

It really makes me sad to see so much negativity and superiority complex in a place that's made to encourage deep thought, differing opinions, and progress for developers.


Atomic CSS isn't a new thing. He's been around for several years and was born before all the new methodologies, and it's a bit obsolete in 2018 since CSS evolved and let us writing more maintainable CSS.

I tell you a thing.. each article about "How to do a THING" you will find an article telling "Don't do this THING"

I can't send you many links about semantic css, against functional CSS (ACSS). Maybe you are interested reading this for a different point of view.


If your way works for you, and my way works for me, why argue that either is right or wrong?

I disagree that css has made atomic obsolete. I think it has allowed atomic to progress actually. Tailwind is a great example.

There is no one way to do everything. I prefer atomic, you prefer semantic. Each are perfectly acceptable when implemented correctly.

For me personally, I very much enjoy being able to quickly understand how my markup will look just by glancing at my class definitions.

Naming classes based on content seems odd to me, as I feel that the new HTML5 semantic elements do that already.

To each their own. Good luck in your future projects!

I never said what is wrong or not. I wrote acss years ago and i just suggested you to see this thing from a different point of view...

Touché. I read your comment in a negative tone, which is definitely on me. Thanks for your insight and point of view. I will definitely give these a read.

Please feel free to drop me a pm or tweet about your conclusions


"leveraging the class attribute which is not supposed to be used for styles at all?"
Classes are not meant for styles?


Yes, "srsly". Go ahead and click the link if you want to see the source.

which link are you referring to? Listen, this:

So instead of learning some CSS, which is an accepted standard, you're going to learn this.

Is not a technically convincing argument - and it won't work to any future colleague.

Facebook is doing it. (check screenshot) Do they not know how to write CSS?
I think someone needs several years of hands on professional experience in big projects. Working and having a product owner/manager/boss who wants you to deliver is not the same as writing a thesis about semantic web for uni.
I learned CSS on a very good level and then decided to follow this pattern because I saw its' power and productivity. This technique has a big following of very VERY senior developers.



Shouldn't a professional be able to use the right tool for the right job? Why is everyone judging this hammer for not being able to drive a screw? I'm definitely not going to over-tool a landing page and contact form with a huge CSS framework.


Hi Corina,
for quick and decent design i've also found w3.css a very lightweight, easy to learn & implement solution.
Now busy with Vue.js i am using bulma.io which has a similar simplicity/elegance out-of-the-box.


Might not matter much to you since you're using a CSS framework, but I wanna mention how awesome Vue Loader's "scoped" attribute is -- it removes the challenges of globally scoped CSS without requiring you to utilize actual web components with something like Polymer. We have unscoped global styles for things like dropdowns, forms, etc. in our root component, and we just scope/customize other components as necessary. We used to practice BEM but just don't need to anymore.


So this is just another CSS Framework, of which there are plenty. In the past I couldn't trust W3 schools because there were a lot of errors in their examples / documentation but they've really improved over the years.

That said, I don't know how new W3.css is but I'd stick with Bootstrap or Bulma over this as they are more tried and true / popularity in this case means trust.


As someone who just wrote a quick project that produced a simple HTML page with no styling (I'm a backend guy, so CSS has always been a struggle for me), this is a nice intro that comes at a timely moment for me. Thanks for sharing!


Welcome to the “Learning libraries instead of technologies” era.


I developed production-size websites and SPAs using functional CSS ( custom-made framework after years of writing CSS, following the logic of tachyons.io/ , and still adhering to principles of cssguidelin.es/ ) and the speed of dev/productivity but also Visual Consistency I was able to achieve with this system was unheard of. (before even Component based architecture was a thing)
The principles behind it?
-> Don't fight with CSS rules - write less of them
-> Semantic Classes are overrated and offer no real-world technical or business advantages (check Facebook's source code)
-> using functional/atomic CSS you can compose "visual components" (even when not using React or Vue) which are repeatable - maintainable - easily redesignable
-> seeing a design you can quickly abstract all the visually repeatable elements, code your base classes, use SASS variables, and have a first draft of your website literally in no time.
Sorry to generalise, but there was a mass influx of ex-backend devs when React et co became a cool thing, and many of them don't really know their shit when it comes to CSS. They just use CSS scoped CSS, repeat everything and think they're doing a cool job serving megabytes of code.


Wow! That looks really neat. Hopefully, this will clear up the clutter and motivate everyone to get on common ground. 🤗


Tailwind CSS (tailwindcss.com) is a great alternative to this with many configuration and integration options, third-party plugins, and an established community.


Interesting enough, I will try it out


Would it not be better just to use Bootstrap rather than use the W3C? Is there any extra feature that it has that Bootstrap does not?


Probably better off with a more mature toolkit that's been around awhile: tachyons.io


W3.CSS just for learn, not for developer..


Don't make that blanket statement. It solved a problem for the author, and Corina is a developer, so your statement is false.


Are you serious now?
Thats for learning css as a standard.
Not for developing!

Try Bootstrap! Or other CSS frameworks


This is brilliant ! I love w3schools and it's amazing they built their own CSS framework !!


Hmm... Interested in how this framework compares with Bulma


You do this for either a living or a serious hobby and basic CSS is too much?

I feel these frameworks are a jump to far too often.


The funny thing with these "you don't have to learn CSS" frameworks is how you still use CSS keywords and general logic all over the place -- change class to style and you're basically getting a valid CSS string, with some minor punctuation changes.

stye="padding: var(--large)"

Much improve, such differ.


We’re removing these comments because they are in violation of the Code of Conduct. If you have questions, please email yo@dev.to.


This comment doesn't meet the dev.to community guidelines. Please reconsider the way you express yourself around here.


Sure there is.

Your comment is not welcoming. It is not respectful. It does not show empathy for your fellow Dev.to users.

So, it does not meet guidelines.


As a thought exercise I encourage you to rethink what you posted and how you can be constructive while giving the same feedback. What words could you change?

Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

Looks totally awful and unusable in real projects. At max one can use it for some simple landing page. For a little advanced styles and markup it would be a hell editing CSS that way. Moreover, it's violating all rules and approaches that we stated to make web beautiful. No semantic HTML, no BEM classes, just inline CSS basically. Why would you even choose it instead inline CSS if it's basically same thing?

This approach has absolutely 0 use case.