0

I want give border via inbuild CSS in XML for a blog. See the sample: iPhone 12 mini. I have add the following code:

.table{
  border: 1px solid black;
}

But, it does not give a border. Any ideas?

0

3 Answers 3

2

Check if you have assigned the right class to the element you want to style. On the sample page there are no elements with the .table class.

If you can only access CSS and you want to style elements on the page over which you don't have direct control, you can try to select elements by their name, their classes, IDs and other attributes using CSS selectors. You can use both single selectors and combination of them to obtain the specificity you need. There is also !important CSS property which you can better not use to avoid maintenance difficulties of the code.

1

In your sample there are 2 things that can cause your problem:

  1. there is a RESET CSS that include table with border: 0;

and

  1. in your css code you tried, you used .table - this means that your table has a class="table", and from what I saw in the sample, that is not the case.

My sugestion is either to add the class="table" to your table and try again your css...

Something like so:

.table{
  border: 1px solid black;
}

<body>
  <table class="table" border="1">
    ...
  </table>
</body>

Or remove the dot (and the need to include a class) - and use in your css simply :

table {
  border: 1px solid black;
}

Mind you that this code, as per your sample css, only put a border around the table and not on all inner elements of said table.

1
  • Thanks a lot. I have made RESET CSS > border: 1; It's works now.
    – Dan 2020
    Apr 12, 2021 at 18:57
0

Adding a border to the table doesn't have anything to do with CSS. You need to add an HTML Attribute Instead.

<HTML>
...
<body>
  <table border="1">
    ...
  </table>
</body>
...
<HTML>

CSS Borders are for decorations, bordering an image etc... While <table> doesn't use CSS Tables to make it visible, It can be added for decoration later, But it still requires the Border HTML Attribute.

1
  • You can use CSS Borders to decorate tables. May 27, 2021 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.