Can anyone help please? Im having trouble getting 4 columns of text, individually ID’d to align horizontally. Im trying to layout 4 columns, using HTML and CSS:
Im a beginner coder. the gifs are small camera icons and there’s a layout attached. Any help would be appreciated.
My current HTML is:
<!–Start of footer text–>
<div id="footer_text">
<div id="1of4"><h3>New car review:Mazda CX-5 Akera</h3>
<img src="images/4_stars.gif">
Bigger engine gives class leading compact SUV the grunt its chassis the grunt it deserves.
<h4>Read more</h4>
<img src="images/camera_col_1.gif" alt="pics" width="25" height="24">
</div>
<div id="2of4"> <h3>Volkswagen Passat Alltrack V Subaru Outback</h3>
High-riding desel wagons out to the test.
<h4>Read more</h4>
</div>
<div id="3of4"><h3>Used car review: Nissan 370Z 2009-2012</h3><img src="../Bushfire_article/images/3_stars.gif" alt="3 stars">
High-riding diesel wagons out to the test.
<h4>Read more</h4>
<img src="images/camera_col_1.gif" alt="pics" width="25" height="24"> </div>
<div id="4of4"><h3>Quick Spin: Subaru Forester XT Premium</h3>
Subaru loads all of its best gear into the range-topiing Forester, pushing into the price league of European rivals
<h4>Read more</h4>
<img src="images/camera_col_1.gif" width="25" height="24"> </div>
Ive just had a breakthrough here - naming my Id;s differently, using text before the numerals so, id is now named div id=“col1of4”…everything jumped into place…If anyone has other suggestion ,please let me know.
As the styles are the same you can just use the same class for each of the columns.
(Note that ie7 and under will probably round the percentage columns up causing one column to drop down. If you are supporting those old browsers then you would need to reduce the width of the last column slightly.)
Hi Paul, really appreciate the feedback, thankyou, asI thirsty for the knowledge right now.!
I was going to group those column classes as you ve indicated, but I wanted control over each individual column width,
so I classed them out separately. Is that the correct procedure?
It all depends on what rules you are applying and if they are all different then you have no choice but to use separate rules but its better to use classes rather than ids because ids are not reusable on the same page and should be used for more structural elements that are not likely to be repeated again on the same page or for hooks for javascript.
If you have a series of common rules then you could do something like this instead with multiple classes.
Multiple classes give you the ability to modify the styles n that rule without having to create a whole new set of duplicate rules. It’s best not to overdo it but they can be very useful for setting up exceptions or over-rides.