Table styling adjustments
November 17, 2024 ยท AI Conversations
<table style="width:70%; border-collapse: separate; border-spacing: 0 10px; border: 1px solid lightgrey;">
<tr>
<th><?php echo __('Are you applying as an individual provider or an organization?') ?></th>
<td><?php echo $user_details['provider_type'] ?></td>
</tr>
<tr>
<th><?php echo __('Name') ?></th>
<td><?php echo $user_details['first_name'].' '.$user_details['last_name'] ?></td>
</tr>
<tr>
<th><?php echo __('Provider / Organization Name') ?></th>
<td><?php echo $user_details['place_title'] ?></td>
</tr>
<tr>
<th><?php echo __('How do you provide your services') ?></th>
<td><?php echo $user_details['virtual_or_in_person'] ?></td>
</tr>
<tr>
<th><?php echo __('Email') ?></th>
<td><?php echo $user_details['email'] ?></td>
</tr>
<tr>
<th><?php echo __('List up to 3 aspects of your services') ?></th>
<td><?php
if(is_array($user_details['services_offered_service_name'])) {
echo implode("<br>", $user_details['services_offered_service_name']);
}
?></td>
</tr>
<tr>
<th><?php echo __('Note any licensing information relative to this application') ?></th>
<td><?php echo $user_details['licensing_info']; ?></td>
</tr>
<tr>
<th><?php echo __('Business Mailing Address') ?></th>
<td><?php
echo $user_details['street'].','.$user_details['city_name'].','.$user_details['state'].','.$user_details['zip_code'];
?></td>
</tr>
<tr>
<th><?php echo __('What services do you provide?') ?></th>
<td><?php
$term_ids = $user_details['services']; // Replace with the actual array of term IDs
$term_names = [];
if(count($term_ids)>0) {
foreach ($term_ids as $term_id) {
$term = get_term($term_id, 'gd_placecategory'); // 'gd_placecategory' is the taxonomy name
if (!is_wp_error($term)) {
// If valid term, add its name to the array
$term_names[] = $term->name;
}
}
if (!empty($term_names)) {
echo implode(', ', $term_names);
} else {
echo 'No service found.';
}
}
?></td>
</tr>
<tr>
<th><?php echo __('Website') ?></th>
<td><?php echo $user_details['website']; ?></td>
</tr>
</table>
### Key Changes:
1. **Table Border**: Set a light grey border with `border: 1px solid lightgrey;`.
2. **Margin between Rows**: Set `border-collapse: separate;` and `border-spacing: 0 10px;` to add 10px margin between rows.
<table style="width:70%; border-collapse: separate; border-spacing: 0 10px; border: 1px solid lightgrey;">
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('Are you applying as an individual provider or an organization?') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['provider_type'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('Name') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['first_name'].' '.$user_details['last_name'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('Provider / Organization Name') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['place_title'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('How do you provide your services') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['virtual_or_in_person'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('Email') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['email'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('List up to 3 aspects of your services') ?></th>
<td style="border: 1px solid lightgrey;"><?php
if(is_array($user_details['services_offered_service_name'])) {
echo implode("<br>", $user_details['services_offered_service_name']);
}
?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('Note any licensing information relative to this application') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['licensing_info']; ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('Business Mailing Address') ?></th>
<td style="border: 1px solid lightgrey;"><?php
echo $user_details['street'].','.$user_details['city_name'].','.$user_details['state'].','.$user_details['zip_code'];
?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('What services do you provide?') ?></th>
<td style="border: 1px solid lightgrey;"><?php
$term_ids = $user_details['services']; // Replace with the actual array of term IDs
$term_names = [];
if(count($term_ids)>0) {
foreach ($term_ids as $term_id) {
$term = get_term($term_id, 'gd_placecategory'); // 'gd_placecategory' is the taxonomy name
if (!is_wp_error($term)) {
// If valid term, add its name to the array
$term_names[] = $term->name;
}
}
if (!empty($term_names)) {
echo implode(', ', $term_names);
} else {
echo 'No service found.';
}
}
?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey;"><?php echo __('Website') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['website']; ?></td>
</tr>
</table>
### Key Changes:
– **Borders on `th` and `td`**: Both “ and “ elements now have a `border: 1px solid lightgrey;` style applied, ensuring that each cell in the table has a border.
– **Spacing between rows**: The `border-spacing: 0 10px;` style still adds a 10px gap between rows.
<table style="width:70%; border-collapse: separate; border-spacing: 0 10px; border: 1px solid lightgrey;">
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('Are you applying as an individual provider or an organization?') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['provider_type'] ?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('Name') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['first_name'].' '.$user_details['last_name'] ?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('Provider / Organization Name') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['place_title'] ?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('How do you provide your services') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['virtual_or_in_person'] ?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('Email') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['email'] ?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('List up to 3 aspects of your services') ?></th>
<td style="border: 1px solid lightgrey;"><?php
if(is_array($user_details['services_offered_service_name'])) {
echo implode("<br>", $user_details['services_offered_service_name']);
}
?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('Note any licensing information relative to this application') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['licensing_info']; ?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('Business Mailing Address') ?></th>
<td style="border: 1px solid lightgrey;"><?php
echo $user_details['street'].','.$user_details['city_name'].','.$user_details['state'].','.$user_details['zip_code'];
?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('What services do you provide?') ?></th>
<td style="border: 1px solid lightgrey;"><?php
$term_ids = $user_details['services']; // Replace with the actual array of term IDs
$term_names = [];
if(count($term_ids)>0) {
foreach ($term_ids as $term_id) {
$term = get_term($term_id, 'gd_placecategory'); // 'gd_placecategory' is the taxonomy name
if (!is_wp_error($term)) {
// If valid term, add its name to the array
$term_names[] = $term->name;
}
}
if (!empty($term_names)) {
echo implode(', ', $term_names);
} else {
echo 'No service found.';
}
}
?></td>
</tr>
<tr style="height: 40px;">
<th style="border: 1px solid lightgrey;"><?php echo __('Website') ?></th>
<td style="border: 1px solid lightgrey;"><?php echo $user_details['website']; ?></td>
</tr>
</table>
### Key Change:
– **Row Height**: The `style="height: 40px;"` is added to each “ element, which sets the height of each row to 40px. You can change `40px` to any value you prefer to adjust the row height.
If you'd like to set a minimum or maximum height, you could use `min-height` or `max-height` instead of `height`.
<table style="width:70%; border-collapse: separate; border-spacing: 0 10px; border: 1px solid lightgrey;">
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('Are you applying as an individual provider or an organization?') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo $user_details['provider_type'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('Name') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo $user_details['first_name'].' '.$user_details['last_name'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('Provider / Organization Name') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo $user_details['place_title'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('How do you provide your services') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo $user_details['virtual_or_in_person'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('Email') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo $user_details['email'] ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('List up to 3 aspects of your services') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php
if(is_array($user_details['services_offered_service_name'])) {
echo implode("<br>", $user_details['services_offered_service_name']);
}
?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('Note any licensing information relative to this application') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo $user_details['licensing_info']; ?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('Business Mailing Address') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php
echo $user_details['street'].','.$user_details['city_name'].','.$user_details['state'].','.$user_details['zip_code'];
?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('What services do you provide?') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php
$term_ids = $user_details['services']; // Replace with the actual array of term IDs
$term_names = [];
if(count($term_ids)>0) {
foreach ($term_ids as $term_id) {
$term = get_term($term_id, 'gd_placecategory'); // 'gd_placecategory' is the taxonomy name
if (!is_wp_error($term)) {
// If valid term, add its name to the array
$term_names[] = $term->name;
}
}
if (!empty($term_names)) {
echo implode(', ', $term_names);
} else {
echo 'No service found.';
}
}
?></td>
</tr>
<tr>
<th style="border: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo __('Website') ?></th>
<td style="border-bottom: 1px solid lightgrey; padding-top: 10px; padding-bottom: 10px;"><?php echo $user_details['website']; ?></td>
</tr>
</table>
### Key Changes:
1. **Padding in `th` and `td`**: I added `padding-top: 10px; padding-bottom: 10px;` to both “ and “ to give top and bottom padding within the cells.
2. **Bottom Border for `td`**: The `td` elements now have `border-bottom: 1px solid lightgrey;` to only add a border at the bottom of the cell, not on the sides or top.
You can adjust the padding values (`10px` here) based on your design preferences.