Does CSS Grid work with php _includes?


#1

I’ve been reading and reading online and can’t find an answer so am turning to you folks. I’d like to try building a website using CSS Grid but I’d also like to do it in .php instead of .html so that I can use _includes for the header, footer and side menu. Is this possible? Or is there a way to use _includes with html instead of PHP?


#2

Hi,
Grid is just another layout tool in addition to floats, display table or flex, it won’t cause any problems with php.

The browser will render your php as html, then you style that html with any CSS.

The question is… Does your new site really need to use Grid or are you wanting to use it because it’s something new?

Just use whatever tool you need to accomplish your goal.


#3

Thanks Ray. I probably don’t NEED to use Grid but I’m toying with a new site and thought I’d try it because it seems to be so much simpler for responsive design than what I’ve done in the past. The older I get the harder it is to get my brain around this stuff, so simple is good. :>) Plus with the minimalistic coding of Grid, the files are much more efficient. I like the idea of having most of the coding in the CSS file instead of in the html/php file.


#4

Yes, by all means do play around with it and see how it goes.

You may also find that the entire site will not need to be in a grid. Like flexbox you can just use it where you need it to help simplify things.

As long as you build a fluid site that will help you greatly in keeping it responsive. Then you use media queries when needed. You don’t need a new media query for every 100px of site width. In fact, a well designed fluid site can get away one media query for mobiles.


#5

Thanks so much Ray.