Replies To: CSS button to change page font-size

Re: CSS button to change page font-size

Posted 03 March 2013 - 09:08 AM

No, that is not correct.

Firstly, the img does not have the class 'btn'.
You cannot nest css-rules like that (with h1 { } inside of img.btn { }).
Css-rules cannot, in any case, refer to elements other than child (or adjacent) elements.
If you want something to happen when you click a button you need to create Javascript code to do this.

Re: CSS button to change page font-size

It does work, I'll give you that. How "fine", however, is highly questionable. Compared to Javascript, it's painfully limited, and it's not supported on anything older than IE9.

Realistically not an option for most web development. Not yet, anyway.

To expand on Atli a bit more. When it come so to Web Development, you have to remember that not everyone will have the latest browsers/computers, especially if your demographic is older (Or low income). So it's best to use something that all browsers can use. Javascript in this would be best (Such as an onclick function to change the CSS).

Re: CSS button to change page font-size

Posted 17 March 2013 - 09:03 AM

If you have jQuery loaded, then I would agree. However if it's not, then this isn't really any reason to load it. (It's fairly expensive to load a library like jQuery.) This would work just as well in pretty much all browsers:

P.S.
Your HTML structure is all messed up. There should at the very least be a Doctype, a <head> and a <body> section. Even in simple examples! (While we know better than to use this type of truncated example structure in real code, passing newbies may not.)